JSON Array Name Change in Python -


i need change name of json array @ beginning of json "data" in python. right receiving , printing out json this:

c = db.cursor() c.execute('select * stuff') return json.dumps(c.fetchall()) 

here json:

[       {            status: "f",            id_num: "001",       },       {            status: "t",            id_num: "002",       },       {            status: "t",            id_num: "003",       } ] 

what need insert "data": right before first square bracket indicating array?

just wrap list in new dictionary:

return json.dumps({'data': c.fetchall()}) 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -