code: def obj_cursor_to_json(self, cursor):
          
          json_object = json.loads(json_util.dumps(cursor))
  
          if "_id" in json_object:
              json_object['id'] = str(json_object['_id']['$oid'])
              del json_object['_id']
  
          return json_object
docs: Handle conversion of pymongo cursor into a JSON object formatted for UI consumption
  
          :param Cursor cursor: A motor client database cursor