我想要做的是用 Python 将 Json 数据作为列表(或数组)取出,我尝试了几次但没有奏效。我的json数据是这样的:
{
"status":"OK",
"List":{
"stuff":[{
"id":"326",
"name":"a",
"url":"autob-fulla.tgz",
},{
"id":"327",
"name":"b",
"url":"auto-fullb.tgz",
},{
"id":"328",
"name":"c",
"url":"auto-fullc.tgz",
}]
}
}
我想返回“id”的所有值。现在我的代码是这样的:
import json
def retrieve():
print('retrieving results...')
testQueueID = '1';
base_url1 = 'http://localhost:8080/stuff'
conn = Connection(base_url1, username='admin', password='admin')
resp = conn.request_get("", args={}, headers={'content-type':'application/xml', 'accept':'application/xml'})
decoded_json = json.loads(json.dumps(resp, sort_keys=True, indent=4, skipkeys=True))
return decoded_json