Skip to content

Instantly share code, notes, and snippets.

@AlexJoz
Created April 14, 2017 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexJoz/0f55e6dc46b9a2f2e49bf29618cda1fb to your computer and use it in GitHub Desktop.
Save AlexJoz/0f55e6dc46b9a2f2e49bf29618cda1fb to your computer and use it in GitHub Desktop.
JSON ENCODER for ObjectID from MongoDB
class JSONEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, ObjectId):
return str(o)
return json.JSONEncoder.default(self, o)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment