convert pymongo cursor to json
It looks like you want to import from bson not pymongo. I believe json_util was moved to that module recently. https://pymongo.readthedocs.io/en/stable/api/bson/json_util.html
It looks like you want to import from bson not pymongo. I believe json_util was moved to that module recently. https://pymongo.readthedocs.io/en/stable/api/bson/json_util.html
The following code will convert the entire result set (Cursor) into a list: myresults = list(mydb.mycollection.find()) This is fine for relatively small result sets, as you are pulling everything into memory.
ObjectId.toString() and ObjectId.valueOf() are in Mongo JavaScript API. In Python API (with PyMongo) proper way is to use pythonic str(object_id) as you suggested in comment, see documentation on ObjectId.