I am using Python 3.8.x and I do get the JSON Serialization error with DATETIME fields in MongoDB documents when retrieving a bunch of collections/documents in pymongo. If it is one document and I know the field, I can explicitly use a customer encoder like those mentioned at How to overcome "datetime.datetime not JSON serializable"?
But since I don't know which collections/documents have DATETIME fields, how can I apply a transformation or masking rule on all documents in a collection?