我正在使用 openweathermap.org 获取一个城市的天气。
jsonp 调用正常,一切正常,但生成的对象包含未知单位的温度:
{
//...
"main": {
"temp": 290.38, // What unit of measurement is this?
"pressure": 1005,
"humidity": 72,
"temp_min": 289.25,
"temp_max": 291.85
},
//...
}
这是一个 console.log
的完整对象的演示。
我认为结果温度不是华氏度,因为将 290.38
华氏度转换为摄氏度是 143.544
。
有谁知道 openweathermap 返回的温度单位是多少?
最佳答案
看起来像 kelvin .将开尔文转换为摄氏度很简单:只需减去 273.15。
看the API documentation ,如果您将 &units=metric
添加到您的请求中,您将获得摄氏度。
关于javascript - 如何计算 openweathermap.org JSON 中返回的摄氏温度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19477324/
相关文章:
javascript - 使用 jQuery 进行跨域 ajax JSONP 请求
java - 想要隐藏由 Jackson 映射到 JSON 的对象的某些字段
json - 如何使用应用引擎 Python webapp2 正确输出 JSON?
json - 从 Newtonsoft 的 JSON 序列化器解析 JSON 日期时间
django - 在 JSON 中返回纯 Django 表单错误
javascript - react router v^4.0.0 Uncaught TypeErr
javascript - jQuery.getJSON - 访问控制允许来源问题