简体   繁体   English

我如何用simplejson在python中编写代码

[英]How Do I code this in python with simplejson

how do i code a python program that return a json element that look like this 我该如何编码返回如下所示的json元素的python程序

{1:{'name':foo,'age':xl}
  2:{'name':vee,'age':xx}
  ....
}

What i meant is that i want return nested dictionaries 我的意思是我想返回嵌套字典

What i hoped to accomplish is something like this 我希望做到的是这样的

var foo = 1.name  # to the the value of name in the clientside

I hope all this made sense .English is my second language 我希望所有这些都有意义。英语是我的第二语言

thanks in advance 提前致谢

>>> 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}]}'
>>> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM