我如何编写一个返回一个看起来像这个
的json元素的python程序{1:{'name':foo,'age':xl}
2:{'name':vee,'age':xx}
....
}
我的意思是我想要返回嵌套字典
我希望完成的是这样的事情
var foo = 1.name # to the the value of name in the clientside
我希望这一切都有道理。英语是我的第二语言
提前致谢
答案 0 :(得分:3)
>>> import simplejson as json
# "simplejson" works exactly the same as with "json"
>>> json.dumps({})
'{}'
>>> json.dumps({'asdf':1,'poi':[2,3,4,{'qwer':5}]})
'{"asdf": 1, "poi": [2, 3, 4, {"qwer": 5}]}'
>>>