如何消除 Open Weather Map API 提供的 JSON 天气预报的歧义?

How to disambiguate the JSON weather forecast provided by the Open Weather Map API?

与 Yahoo Weather API 不同,Open Weather(特别是 JSON)的天气预报响应不包含有关日期和日期的详细信息。我只是得到一份预测数据列表。我怎么知道哪个预报对应哪一天?该列表是否包含特定天数(连续 7 天?)的预测,包括今天及以后,还是明天及以后?

这是每日天气预报文档的 link: http://openweathermap.org/forecast16

这是一个 JSON 编辑器,用于查看 JSON 响应: http://www.jsoneditoronline.org/

这是一个示例响应:

{"city":{"id":1172451,"name":"Lahore","coord":{"lon":74.343613,"lat":31.549721},"country":"PK","population":0},"cod":"200","message":0.0099,"cnt":5,"list":[{"dt":1438758000,"temp":{"day":31.45,"min":26.37,"max":31.45,"night":26.37,"eve":30.71,"morn":31.45},"pressure":984.75,"humidity":79,"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02d"}],"speed":3.83,"deg":119,"clouds":20},{"dt":1438844400,"temp":{"day":26.39,"min":24.36,"max":29.98,"night":25.71,"eve":29.93,"morn":25.13},"pressure":986.81,"humidity":100,"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}],"speed":3.22,"deg":78,"clouds":56,"rain":28.51},{"dt":1438930800,"temp":{"day":31.44,"min":25.78,"max":33.25,"night":27.22,"eve":33.25,"morn":25.78},"pressure":988.04,"humidity":85,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"speed":2.11,"deg":125,"clouds":20,"rain":3.22},{"dt":1439017200,"temp":{"day":28.41,"min":25.8,"max":31.69,"night":27.59,"eve":31.69,"morn":25.8},"pressure":990.43,"humidity":90,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"speed":2.52,"deg":87,"clouds":92,"rain":7.27},{"dt":1439103600,"temp":{"day":31.35,"min":26.23,"max":33.56,"night":27.29,"eve":31.68,"morn":26.23},"pressure":987.94,"humidity":81,"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"speed":1.51,"deg":99,"clouds":44,"rain":2.59}]}

如果我没记错的话,dt 就是当天的时间戳。 你可以看看Weatherlib。它是我编写的一个开源库,用于解析 OWM 数据和其他天气提供程序。 希望对你有帮助。