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
Post a Comment