My Python code queries a MongoDB and gets back an array of the following objects:
{
u'attribute': u'value',
u'_id': ObjectId('534776c66e5987041f6154bd')
}
What I want to achieve, is to return the following JSON:
{
'mycollectionkey' : [
{
'attribute':'value',
'_id': ObjectId('534776c66e5987041f6154bd')
},
...and so on.
]
}
However, when I do:
docs = mongodb.find(...query...)
docs_json = bson.json_util.dumps(docs)
return flask.jsonify(success=True,mycollectionkey=docs_json)
I get: { 'mycollectionkey' : "*giant string representation of data*" } where said giant string, clearly is no longer JSON.