Tutorial by Examples

json_util provides two helper methods, dumps and loads, that wrap the native json methods and provide explicit BSON conversion to and from json. Simple usage from bson.json_util import loads, dumps record = db.movies.find_one() json_str = dumps(record) record2 = loads(json_str) if record is:...
python-bsonjs does not depend on PyMongo and can offer a nice performance improvement over json_util: bsonjs is roughly 10-15x faster than PyMongo’s json_util at decoding BSON to JSON and encoding JSON to BSON. Note that: to use bsonjs effectively, it is recommended to work directly with Ra...
If all you need is serializing mongo results into json, it is possible to use the json module, provided you define custom handlers to deal with non-serializable fields types. One advantage is that you have full power on how you encode specific fields, like the datetime representation. Here is a ha...

Page 1 of 1