MSW API指出:
我们的 API 遵循 RESTful 约定。查询位置信息就像调用一样简单:http ://magicseaweed.com/api/YOURAPIKEY/forecast/?spot_id=10
您将收到一个 JSON 数组,其中包含一系列代表特定时间范围内预测的数据,如下所示:
[
{
"timestamp": 1367366400,
"localTimestamp": 1367366400,
"issueTimestamp": 1367366400,
"fadedRating": 0,
"solidRating": 0,
"swell": {
"minBreakingHeight": 1,
"absMinBreakingHeight": 0.504,
"maxBreakingHeight": 1,
"absMaxBreakingHeight": 0.784,
"unit": "ft",
"components": {
"combined": {
"height": 1.6,
"period": 5,
"direction": 252.47,
"compassDirection": "ENE"
},
"primary": {
"height": 0.5,
"period": 7,
"direction": 92.49,
"compassDirection": "W"
},
"secondary": {
"height": 0.2,
"period": 9,
"direction": 52.9,
"compassDirection": "SW"
},
"tertiary": {
"height": 1.5,
"period": 5,
"direction": 248.62,
"compassDirection": "ENE"
}
}
},
"wind": {
"speed": 6,
"direction": 221,
"compassDirection": "NE",
"chill": 32,
"gusts": 9,
"unit": "mph"
},
"condition": {
"pressure": 1026,
"temperature": 39,
"weather": "10",
"unitPressure": "mb",
"unit": "f"
},
"charts": {
"swell": "htt://chart-1-us.msw.ms/wave/750/1-1367366400-1.gif",
"period": "htt://chart-1-us.msw.ms/wave/750/1-1367366400-2.gif",
"wind": "htt://chart-1-us.msw.ms/gfs/750/1-1367366400-4.gif",
"pressure": "htt://chart-1-us.msw.ms/gfs/750/1-1367366400-3.gif",
"sst": "htt://chart-1-us.msw.ms/sst/750/1-1367366400-10.gif"
}
},
{
"timestamp": 1367377200,
"localTimestamp": 1367377200,
"issueTimestamp": 1367366400,
"fadedRating": 0,
"solidRating": 0,
"swell": {
"minBreakingHeight": 0,
"absMinBreakingHeight": 0.384,
"maxBreakingHeight": 1,
"absMaxBreakingHeight": 0.6,
"unit": "ft",
"components": {
"combined": {
"height": 1.8,
"period": 4,
"direction": 266.06,
"compassDirection": "E"
},
"primary": {
"height": 0.4,
"period": 6,
"direction": 92.53,
"compassDirection": "W"
},
"secondary": {
"height": 0.2,
"period": 9,
"direction": 52.72,
"compassDirection": "SW"
},
"tertiary": {
"height": 1.8,
"period": 4,
"direction": 258.73,
"compassDirection": "ENE"
}
}
},
"wind": {
"speed": 5,
"direction": 255,
"compassDirection": "ENE",
"chill": 34,
"gusts": 7,
"unit": "mph"
},
"condition": {
"pressure": 1025,
"temperature": 41,
"weather": "10",
"unitPressure": "mb",
"unit": "f"
},
"charts": {
"swell": "htt://chart-1-us.msw.ms/wave/750/1-1367377200-1.gif",
"period": "htt://chart-1-us.msw.ms/wave/750/1-1367377200-2.gif",
"wind": "htt://chart-1-us.msw.ms/gfs/750/1-1367377200-4.gif",
"pressure": "htt://chart-1-us.msw.ms/gfs/750/1-1367377200-3.gif",
"sst": "htt://chart-1-us.msw.ms/sst/750/1-1367377200-10.gif"
}
}, THIS CONTINUES ON UNTIL THE END OF THE ARRAY
如何调用 JSON 数组以及如何为每个项目分配一个变量(或访问每个项目以便稍后在 html 等中使用)?
谢谢。