如何消除歧义由Open天气地图API提供的JSON天气预报? [英] How to disambiguate the JSON weather forecast provided by the Open Weather Map API?

查看:373
本文介绍了如何消除歧义由Open天气地图API提供的JSON天气预报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与雅虎天气API,从打开天气天气预报响应(JSON尤其是)不包含有关星期和日期的详细信息。我只是得到的预测数据的列表。我怎么知道哪些预测对应的是哪一天?是否列表包含天特定数量的预测(连续7天?),包括今天及以后,或者是明天及以后?

下面是为每日天气预报的文档的链接:
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},\"$p$pssure\":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},\"$p$pssure\":986.81,\"humidity\":100,\"weather\":[{\"id\":502,\"main\":\"Rain\",\"description\":\"heavy
  强度
  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},\"$p$pssure\":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},\"$p$pssure\":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},\"$p$pssure\":987.94,\"humidity\":81,\"weather\":[{\"id\":500,\"main\":\"Rain\",\"description\":\"light
  雨,图标:10D}],速度:1.51,度:99,祥云:44,雨:2.59}​​]}



解决方案

如果我没错的DT是一天的时间戳。
你可以给看看 Weatherlib 。这是我写的一个开放源码库,分析数据OWM和其他天气提供商。
希望它可以帮助你。

Unlike Yahoo Weather API, the weather forecast response from Open Weather (JSON in particular) contains no details about Day and Date. I simply get a list of forecast data. How am I supposed to know which forecast corresponds to which day? Does the list contain a forecast of a specific number of days (7 consecutive days?) including today and onward, or is it tomorrow and onward?

Here is a link to the documentation for the daily weather forecast: http://openweathermap.org/forecast16

Here is a JSON editor to view the JSON response : http://www.jsoneditoronline.org/

Here is an example response:

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

解决方案

If i'm not wrong the dt is the timestamp of the day. You can give a look at Weatherlib. It is an open source library written by me that parse OWM data and other weather provider. Hope it helps you.

这篇关于如何消除歧义由Open天气地图API提供的JSON天气预报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆