1 レベルよりも深い JSON オブジェクトをループする方法がわかりません。オブジェクトは次のとおりです。
{
"data":[
{
"id":"251228454889939/insights/page_fan_adds_unique/day",
"name":"page_fan_adds_unique",
"period":"day",
"values":[
{
"value":9,
"end_time":"2012-05-29T07:00:00+0000"
},
{
"value":5,
"end_time":"2012-05-30T07:00:00+0000"
}
],
"title":"Daily New Likes",
"description":"Daily The number of new people who have liked your Page (Unique Users)"
},
{
"id":"251228454889939/insights/page_fan_adds/day",
"name":"page_fan_adds",
"period":"day",
"values":[
{
"value":9,
"end_time":"2012-05-29T07:00:00+0000"
},
{
"value":5,
"end_time":"2012-05-30T07:00:00+0000"
}
],
"title":"Daily New Likes",
"description":"Daily The number of new people who have liked your Page (Total Count)"
}
]
}
コード:
def parseJsonData(data):
output_json = json.loads(data)
for i in output_json:
print i
for k in output_json[i]:
print k
次のようなオブジェクトにアクセスできないのはoutput_json[data][id]
なぜですか? これを試すとエラーが発生します:
文字列インデックスは整数でなければなりません