Created
July 27, 2010 23:40
-
-
Save mumrah/493065 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from json import JSONEncoder | |
from pymongo.objectid import ObjectId | |
class MongoEncoder(JSONEncoder): | |
def _iterencode(self, o, markers=None): | |
if isinstance(o, ObjectId): | |
return """ObjectId("%s")""" % str(o) | |
else: | |
return JSONEncoder._iterencode(self, o, markers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A custom JSON encoder for serializing mongoDB ObjectIds