I'm struggling to figure out how to parse the data from the Wunderground API. I am using the API to get a JSON object for the current observation. The object looks like:
{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"conditions": 1
}
}
, "current_observation": {
"image": {
"url":"http://icons.wxug.com/graphics/wu2/logo_130x80.png",
"title":"Weather Underground",
"link":"http://www.wunderground.com"
},
"display_location": {
"full":"Greentown, IN",
"city":"Greentown",
"state":"IN",
"state_name":"Indiana",
"country":"US",
"country_iso3166":"US",
"zip":"46936",
"magic":"1",
"wmo":"99999",
"latitude":"40.47999954",
"longitude":"-85.97000122",
"elevation":"256.0"
},
"observation_location": {
"full":"Greentown, IN, Greentown, Indiana",
"city":"Greentown, IN, Greentown",
"state":"Indiana",
"country":"US",
"country_iso3166":"US",
"latitude":"40.474854",
"longitude":"-85.956253",
"elevation":"846 ft"
},
"estimated": {
},
"station_id":"KINGREEN32",
"observation_time":"Last Updated on November 13, 8:35 PM EST",
"observation_time_rfc822":"Mon, 13 Nov 2017 20:35:13 -0500",
"observation_epoch":"1510623313",
"local_time_rfc822":"Mon, 13 Nov 2017 20:39:08 -0500",
"local_epoch":"1510623548",
"local_tz_short":"EST",
"local_tz_long":"America/New_York",
"local_tz_offset":"-0500",
"weather":"Mostly Cloudy",
"temperature_string":"33.4 F (0.8 C)",
"temp_f":33.4,
"temp_c":0.8,
"relative_humidity":"91%",
"wind_string":"Calm",
"wind_dir":"WNW",
"wind_degrees":303,
"wind_mph":0.0,
"wind_gust_mph":"5.0",
"wind_kph":0,
"wind_gust_kph":"8.0",
"pressure_mb":"1030",
"pressure_in":"30.43",
"pressure_trend":"0",
"dewpoint_string":"31 F (-0 C)",
"dewpoint_f":31,
"dewpoint_c":-0,
"heat_index_string":"NA",
"heat_index_f":"NA",
"heat_index_c":"NA",
"windchill_string":"33 F (1 C)",
"windchill_f":"33",
"windchill_c":"1",
"feelslike_string":"33 F (1 C)",
"feelslike_f":"33",
"feelslike_c":"1",
"visibility_mi":"2.5",
"visibility_km":"4.0",
"solarradiation":"0",
"UV":"0.0","precip_1hr_string":"0.00 in ( 0 mm)",
"precip_1hr_in":"0.00",
"precip_1hr_metric":" 0",
"precip_today_string":"0.00 in (0 mm)",
"precip_today_in":"0.00",
"precip_today_metric":"0",
"icon":"mostlycloudy",
"icon_url":"http://icons.wxug.com/i/c/k/nt_mostlycloudy.gif",
"forecast_url":"http://www.wunderground.com/US/IN/Greentown.html",
"history_url":"http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KINGREEN32",
"ob_url":"http://www.wunderground.com/cgi-bin/findweather/getForecast?query=40.474854,-85.956253",
"nowcast":""
}
}
I want to parse out the "temp_f" and "feelslike_f" values. I've tried using json_unpack but it seems to use this I would have to list each element in the function call.
How can I do this?