1

我正在使用Open Weather Map API. 我还在玩电话。我正在查看 2 个特定调用的结果。一个是 for London,另一个是 for Hermanusin South Africa。我观察到,并非 Hermanus 调用中返回的所有数据都包含在 London 调用中返回的数据中。

这是我的两个电话:

伦敦返回的数据是:

{
     "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
}

为什么一个包含某些数据而另一个不包含?我怎样才能找出可以从这样的调用中返回的所有内容?我怎么知道退回的每件商品的含义?

4

1 回答 1

1

如果你看一下这个页面,你会看到一些返回的键实际上是可选的:

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

即使是明显的weather键也是可选的!:)

于 2013-09-27T13:08:13.887 回答