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

问题描述

限时删除!!

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

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?

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

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

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

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

这是一个示例响应:

{"city":{"id":1172451,"name":"Lahore","coord":{"lon":74.343613,"lat":31.549721},"country":"PK","人口":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},"压力":984.75,"湿度":79,"天气":[{"id":801,"main":"云","description":"很少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},"压力":986.81,"湿度":100,"天气":[{"id":502,"main":"Rain","description":"重强度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},"压力":988.04,"湿度":85,"天气":[{"id":501,"main":"Rain","description":"中等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},"压力":990.43,"湿度":90,"天气":[{"id":501,"main":"Rain","description":"中等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},"压力":987.94,"湿度":81,"天气":[{"id":500,"main":"Rain","description":"lightrain","icon":"10d"}],"speed":1.51,"deg":99,"clouds":44,"rain":2.59}]}

推荐答案

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

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 Weather Map API 提供的 JSON 天气预报的歧义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 15:58