Created
April 14, 2017 07:48
-
-
Save AlexJoz/0f55e6dc46b9a2f2e49bf29618cda1fb to your computer and use it in GitHub Desktop.
JSON ENCODER for ObjectID from MongoDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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