PyMongo Converting between BSON and JSON

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!


In many applications, records from MongoDB need to be serialized in JSON format. If your records have fields of type date, datetime, objectId, binary, code, etc. you will encounter TypeError: not JSON serializable exceptions when using json.dumps. This topic shows how to overcome this.

Got any PyMongo Question?