好吧,我有一个来自网站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