Wednesday 11 June 2014

mongoengine objects to json

If you want to make json data from mongoengine objects.

example is given from flask framework

@app.route('/json', methods=['GET', 'POST'])
def json_data():
    return Company.objects.all().to_json()



If you want to convert json data into mongodb object try this

c = Company.objects.from_json(company)

3 comments:

Unknown said...

I like what you guys are up also. Such clever work and reporting! Keep up the superb works guys I¡¦ve incorporated you guys to my blogroll. Hadoop Online Training .

AMtlPy said...

Hi !
Thanks for your tip.
Do you know a solution to ignore json fields unknown by the mongoengine model?

Thanks

Unknown said...

nice blog keep blogging for best online hadoop training online hadoop training.
hadoop is the best framework in programing languages learn and get the full knowledge on hadoop.