好吧,我有一個來自網站API的JSON文件,我需要重新排列,以便Highcharts可以讀取數據。我不知道如何繼續。我有一個網址,通過閱讀highcharts網站上的文檔,我需要重新格式化數據才能正確使用,那麼,我應該如何繼續?從API到數組的外部JSON?
我應該設置一個加載JSON文件的PHP文件,然後使用JavaScript來挑選出我想要的?如果是這樣,我將如何實現這一目標?
在此先感謝!
這裏是JSON數據
[
{
"timestamp": 1382918400,
"localTimestamp": 1382918400,
"issueTimestamp": 1382918400,
"fadedRating": 4,
"solidRating": 0,
"swell": {
"minBreakingHeight": 5,
"absMinBreakingHeight": 4.508,
"maxBreakingHeight": 7,
"absMaxBreakingHeight": 7.049,
"unit": "ft",
"components": {
"combined": {
"height": 18,
"period": 10,
"direction": 37.25,
"compassDirection": "SW"
},
"primary": {
"height": 18,
"period": 10,
"direction": 47.09,
"compassDirection": "SW"
}
}
},
"wind": {
"speed": 15,
"direction": 79,
"compassDirection": "W",
"chill": 54,
"gusts": 29,
"unit": "mph"
},
"condition": {
"pressure": 986,
"temperature": 59,
"weather": "23",
"unitPressure": "mb",
"unit": "f"
},
"charts": {
"swell": "http://chart-1.msw.ms/wave/750/1-1382918400-1.gif",
"period": "http://chart-1.msw.ms/wave/750/1-1382918400-2.gif",
"wind": "http://chart-1.msw.ms/gfs/750/1-1382918400-4.gif",
"pressure": "http://chart-1.msw.ms/gfs/750/1-1382918400-3.gif",
"sst": "http://chart-1.msw.ms/sst/750/1-1382918400-10.gif"
}
},
]
這將是有益的,如果你可以給JSON數據的樣本,你擁有和你需要的東西,以及你試圖實現你的目標的代碼。 –
Highcharts有一篇關於它的文章[這裏](http://www.highcharts.com/docs/working-with-data/preprocessing-data-from-a-file-csv-xml-json),但從它的聲音像你有正確的想法。只需使用Javascript來挑選您需要的內容並將其提供給Highcharts。 – aug
@AndrewCooper我已將一些數據添加到帖子中。Thx的幫助! – MacD