-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
The UUID sub type should be encoded as
{ "$binary": "<bindata>", "$type": "<t>" }
according to the documentation:
https://docs.mongodb.com/manual/reference/mongodb-extended-json/#binary
This is also what the server does: https://github.com/mongodb/mongo/blob/master/src/mongo/dbtests/jsontests.cpp#L1396
Example of the current behavior
>>> import bson >>> from bson import json_util >>> from bson.binary import UUID >>> json_util.dumps({'uuid': UUID('f47ac10b-58cc-4372-a567-0e02b2c3d479')}) '{"uuid": {"$uuid": "f47ac10b58cc4372a5670e02b2c3d479"}}'
- is depended on by
-
PYTHON-1111 New codec options for json_util.dumps and loads
- Closed