0
我是JQuery和JSON的新手。我無法從如何從JSON API返回值
jQuery(document).ready(function($) {
$.getJSON(
'http://api.eia.gov/series/?api_key=YourAPIKey&series_id=PET.EMD_EPD2D_PTE_NUS_DPG.W',
function(data){
var content = data series[0].data[0][1]
$('p').append(content);
}
)
});
});
例如JSON返回值:
{"request":{"command":"series","series_id":"PET.EMD_EPD2D_PTE_NUS_DPG.W"},"series":[{"series_id":"PET.EMD_EPD2D_PTE_NUS_DPG.W","name":"U.S. No 2 Diesel Retail Prices, Weekly","units":"Dollars per Gallon","f":"W","unitsshort":"$\/gal","description":"U.S. No 2 Diesel Retail Prices","copyright":"None","source":"EIA, U.S. Energy Information Administration","iso3166":"USA","geography":"USA","start":"19940321","end":"20151012","updated":"2015-10-14T09:50:13-0400","data":[["20151012",2.556],["20151005",2.492],["20150928",2.476],["20150921",2.493],["20150914",2.517],["20150907",2.534],["20150831",2.514],["20150824",2.561],["20150817",2.615],["20150810",2.617],["20150803",2.668],["20150727",2.723],["20150720",2.782],["20150713",2.814],["20150706",2.832],["20150629",2.843],["20150622",2.859], ["20150615",2.87],["20150608",2.884],["20150601",2.909]]}]}
休息中省略爲簡潔起見。
我怎樣才能數據陣列中獲取的第一個值: 「20151012」,2.556 < - 需要這個......