好的,我有一个来自网站 API 的 JSON 文件,我需要重新排列它,以便 Highcharts 可以读取数据。我不知道该怎么做。我有一个 URL,通过阅读 highcharts 网站上的文档,我需要重新格式化数据才能正确使用,那么,我应该如何进行?
我应该设置一个加载 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"
}
},
]