我试图解码与Python以下JSON文件:解码JSON与Python和存储嵌套对象
{"node":[
{
"id":"12387",
"ip":"172.20.0.1",
"hid":"213",
"coord":{"dist":"12","lat":"-9.8257","lon":"65.0880"},
"status":{"speed":"90","direction":"N"},
"ts":"12387"}
]
}
使用:
json_data=open('sampleJSON')
jdata = json.load(json_data)
for key, value in jdata.iteritems():
print "Key:"
print key
print "Value:"
print value
,我有作为输出:
Key:
node
Value:
[{u'status': {u'direction': u'N', u'speed': u'90'}, u'ip': u'172.20.0.1', u'ts': u'12387', u'coord': {u'lat': u'-9.8257', u'lon': u'65.0880', u'dist': u'12'}, u'hid': u'213', u'id': u'12387'}]
而且我希望能够打印键值和嵌套对象的值状态,coord,还有节点,“hid”,“id”,“ip”和“ts”的que键/值。
我如何在所有嵌套值中进行交互?
预先感谢您!
太谢谢你了!它完全钉了它 – Tallis