Created
July 27, 2010 21:29
-
-
Save mumrah/492901 to your computer and use it in GitHub Desktop.
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
>>> x = {'a':1,'b':"foo",'c':ObjectId()} | |
>>> print x | |
{'a': 1, 'c': ObjectId('4c4f4f5e2554c813e4000001'), 'b': 'foo'} | |
>>> print json.dumps(x) | |
Traceback (most recent call last): | |
[...] | |
TypeError: ObjectId('4c4f4f5e2554c813e4000001') is not JSON serializable | |
>>> print json.dumps(x, cls=MongoEncoder) | |
'{"a": 1, "c": ObjectId("4c4f4f5e2554c813e4000001"), "b": "foo"}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment