0
以下是雅虎財經API,我期待提取64.730003從"price": "64.730003"
如何遍歷這個JSON結構
我通過使用下面的嘗試這一點,但我究竟做錯了什麼?我猜測它與data.list.resources.resource.fields.price有關,因爲我似乎無法弄清楚遍歷JSON格式。
$.getJSON("http://finance.yahoo.com/webservice/v1/symbols/BZM15.NYM/quote?format=json")
.done(function (data) {
$("#result").html("$"+ data.list.resources.resource.fields.price);
})
JSON:
{
"list": {
"meta": {
"type": "resource-list",
"start": 0,
"count": 1
},
"resources": [
{
"resource": {
"classname": "Quote",
"fields": {
"name": "Brent Crude Oil Last Day Future",
"price": "64.730003",
"symbol": "BZM15.NYM",
"ts": "1429823631",
"type": "future",
"utctime": "2015-04-23T21:13:51+0000",
"volume": "1"
}
}
}
]
}
}