私がやりたいのは、Json データを Python でリスト (または配列) として取得することです。何度か試しましたが、うまくいきませんでした。私の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