I am using the python package pymongo to retrieve data from a mongodb database.
>>> r = collection.find() # returns an object of class \'Cursor\'
from bson import json_util json.dumps(result,default=json_util.default)