从开放天气图API返回的数据没有意义

时间:2013-09-27 13:00:17

标签: javascript jquery jquery-plugins weather weather-api

我正在使用Open Weather Map API。我还在玩电话。我正在查看2个特定呼叫的结果。一个用于London,另一个用于Hermanus中的South Africa。我观察到,并非Hermanus呼叫中返回的所有数据都来自伦敦呼叫返回的数据。

以下是我的2个电话:

伦敦返回的数据是:

{
     "coord": {
          "lon":-0.12574,
          "lat":51.50853
     },
     "sys": {
          "country":"GB",
          "sunrise":1380261352,
          "sunset":1380303998
     },
     "weather": [{
          "id":800,
          "main":"Clear",
          "description":"Sky is Clear",
          "icon":"01d"
     }],
     "base":"gdps stations",
     "main": {
          "temp":290.22,
          "pressure":1016,
          "humidity":63,
          "temp_min":289.15,
          "temp_max":291.48
     },
     "wind": {
          "speed":6.2,
          "deg":100
     },
     "clouds": {
          "all":0
     },
     "dt":1380285272,
     "id":2643743,
     "name":"London",
     "cod":200
}

Hermanus返回的数据是:

{
     "coord": {
          "lon":19.234461,
          "lat":-34.418701
     },
     "sys": {
          "country":"ZA",
          "sunrise":1380255856,
          "sunset":1380300203
     },
     "weather": [{
          "id":804,
          "main":"Clouds",
          "description":"overcast clouds",
          "icon":"04d"
     }],
     "base":"gdps stations",
     "main": {
          "temp":284.981,
          "temp_min":284.981,
          "temp_max":284.981,
          "pressure":999.07,
          "sea_level":1026.12,
          "grnd_level":999.07,
          "humidity":77
     },
     "wind": {
          "speed":6.71,
          "deg":282
     },
     "rain": {
          "3h":0
     },
     "clouds": {
          "all":92
     },
     "dt":1380285425,
     "id":3366880,
     "name":"Hermanus",
     "cod":200
}

为什么一个包含某些数据而另一个不包含?我怎样才能知道这样的电话可以回复什么?我怎么知道每个项目的含义是什么?

1 个答案:

答案 0 :(得分:1)

如果您查看此页面,您会看到一些返回的键实际上是可选的:

http://openweathermap.org/wiki/API/2.0/Weather_Data

即使是显而易见的weather键也是可选的! :)