text: # -*- coding: utf-8 -*-
  import json
  from bson.objectid import ObjectId
  from datetime import date, datetime  
  class Encoder(json.JSONEncoder):
      
      def default(self, obj):
          if isinstance(obj, ObjectId):
              return str(obj)
          elif isinstance(obj, datetime):
              return obj.strftime('%Y-%m-%d %H:%M:%S')
          elif isinstance(obj, date):
              return obj.strftime('%Y-%m-%d') 
          else:
              return json.JSONEncoder.default(self, obj) 
       