简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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