Unable to deserialize PyMongo ObjectId from JSON
问题 I'm seemingly unable to deserialize my MongoDB JSON document with the BSON json_util. The json.loads function is choking on the ObjectId() string. I had understood json_util capable of handling MongoDB's ObjectId format and transforming into usable JSON. Python code: import json from bson import json_util s = "{u'_id': ObjectId('4ed559abf047050c58000000')}" u = json.loads(s, object_hook=json_util.object_hook) I get the decoder exception: ... u = json.loads(s, object_hook=json_util.object_hook