JSON Parse in python (special case) -


my project receiving json message this:

"listinginfo":{     "438317215072450609":{         "listingid":"438317215072450609",         "price":27044,         "fee":4056,     },     "428184115913903011":{         "listingid":"428184115913903011",         "price":480,         "fee":72,     } } 

in json file, want "438317215072450609" , "428184115913903011". i've tried :

myjson.get('listinginfo').get(*).get(listingid) #and myjson['listinginfo'][0]['listingid'] 

but of course, doesn't work ;) thank in advance (sorry bad english)

you have values twice: once key in outer dict, , once listingid value inside inner dict. first, can do:

myjson['listinginfo'].keys() 

and second, can do:

[d['listingid'] d in myjson['listinginfo'].values()] 

if they're same, of course, doesn't matter of these use.


Comments