Pymongo/bson: Convert python.cursor.Cursor object to serializable/JSON object
问题 New to MongoDb and Python ( webapp2 ). So, I was fetching some data from a mongodb database. But I was unable to use json.dumps on the returned data. Here's my code: exchangedata = db.Stock_Master.find({"Country": "PHILIPPINES"}, {"_id" : 0}) self.response.write(json.dumps(exchangedata)) This throws an error: TypeError: pymongo.cursor.Cursor object at 0x7fcd51230290 is not JSON serializable The type of exchangedata is pymongo.cursor.Cursor . How can I convert it into a json object? 回答1: Use