我想要在JSON API respons迭代,我無法達到我需要迭代通過嵌套JSON
這裏的數據是API響應的例子。 「我知道這不是完整的或有效的JSON :)」
{
"status": "running",
"reasons": [],
"nodes": {
"Server1": {
"status": "running",
,我使用一個簡單的for循環迭代throught吧!
for platforms in sbNode:
request = urllib2.Request(API URL)
json_res = json.load(urllib2.urlopen(request))
for node in json_res['nodes']:
print node['status']
,我收到錯誤消息
類型錯誤:字符串索引必須是整數
和normaly我只是打印for循環看到JSON數據,但它只是打印服務器1 。
我在這裏迷路了....
幫助!!!
謝謝
我們走吧!非常感謝 !! – Arriflex