Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 来自Wunderground API的每小时空气污染指数预测_Json_Api_Wunderground - Fatal编程技术网

Json 来自Wunderground API的每小时空气污染指数预测

Json 来自Wunderground API的每小时空气污染指数预测,json,api,wunderground,Json,Api,Wunderground,我正试图从一个研究项目的Wunderground API中获取一天中特定时间的每小时预测温度: 这是JSON的一个示例: 具体部分如下所示: "hourly_forecast": [ { "FCTTIME": { "hour": "17","hour_padded": "17","min": "00","sec": "0","year": "2013","mon": "7","mon_padded": "07","mon_abbrev": "Jul","mday": "

我正试图从一个研究项目的Wunderground API中获取一天中特定时间的每小时预测温度:

这是JSON的一个示例:

具体部分如下所示:

"hourly_forecast": [
    {
    "FCTTIME": {
    "hour": "17","hour_padded": "17","min": "00","sec": "0","year": "2013","mon": "7","mon_padded": "07","mon_abbrev": "Jul","mday": "15","mday_padded": "15","yday": "195","isdst": "1","epoch": "1373925600","pretty": "5:00 PM CDT on July 15, 2013","civil": "5:00 PM","month_name": "July","month_name_abbrev": "Jul","weekday_name": "Monday","weekday_name_night": "Monday Night","weekday_name_abbrev": "Mon","weekday_name_unlang": "Monday","weekday_name_night_unlang": "Monday Night","ampm": "PM","tz": "","age": ""
    },
    "temp": {"english": "86", "metric": "30"},
    "dewpoint": {"english": "71", "metric": "22"},
    "condition": "Thunderstorm",
    "icon": "tstorms",
    "icon_url":"http://icons-ak.wxug.com/i/c/k/tstorms.gif",
    "fctcode": "15",
    "sky": "66",
    "wspd": {"english": "10", "metric": "16"},
    "wdir": {"dir": "ESE", "degrees": "119"},
    "wx": "Scattered Thunderstorms , Scattered Light Rain Showers",
    "uvi": "3",
    "humidity": "60",
    "windchill": {"english": "-9998", "metric": "-9998"},
    "heatindex": {"english": "91", "metric": "33"},
    "feelslike": {"english": "91", "metric": "33"},
    "qpf": {"english": "", "metric": ""},
    "snow": {"english": "", "metric": ""},
    "pop": "30",
    "mslp": {"english": "30.14", "metric": "1020"}
    }
    ,
我得到的JSON是这样的:

$.ajax({
    url : "http://api.wunderground.com/api/[key]/geolookup/forecast/hourly/history_/astronomy/conditions/q/"+lat+","+lon+".json",
    dataType : "jsonp",
    success : function(parsed_json) {
然后我试着像这样运行每小时预测(通常mday和hour被一个包含今天日期和特定小时的变量替换,但是为了排除故障,我将这些数字放在了里面)

然而,对于六小时的预测,我总是得到错误的临时英语

如此接近-我错过了什么?

这就是原因:

// Get the forecast 6 hour temp
$.each( parsed_json['hourly_forecast'], function( index, value )    {
    if( value['FCTTIME']['hour']==sunrise_hour*1 + 6 && value['FCTTIME']['mday']==window.current_day ) {
    window.six_hour_forecast = value.temp.english;
    }
}); // end each
// Get the forecast 6 hour temp
$.each( parsed_json['hourly_forecast'], function( index, value )    {
    if( value['FCTTIME']['hour']==sunrise_hour*1 + 6 && value['FCTTIME']['mday']==window.current_day ) {
    window.six_hour_forecast = value.temp.english;
    }
}); // end each