JSON serializing Mongodb

后端 未结 5 1472
南笙
南笙 2020-12-05 05:10

I am using the python package pymongo to retrieve data from a mongodb database.

>>> r = collection.find()   # returns an object of class \'Cursor\'
         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 05:39

    from bson import json_util
    
    
    
    json.dumps(result,default=json_util.default)
    

提交回复
热议问题