I am using the Wunderground api to get hourly weather forecast for an android app. I want to receive information like Temp and day.
An example of the Json is:
"hourly_forecast": [
{
"FCTTIME": {
"hour": "11","hour_padded": "11","min": "00","min_unpadded": "0","sec": "0","year": "2014","mon": "7","mon_padded": "07","mon_abbrev": "Jul","mday": "8","mday_padded": "08","yday": "188","isdst": "1","epoch": "1404842400","pretty": "11:00 AM PDT on July 08, 2014","civil": "11:00 AM","month_name": "July","month_name_abbrev": "Jul","weekday_name": "Tuesday","weekday_name_night": "Tuesday Night","weekday_name_abbrev": "Tue","weekday_name_unlang": "Tuesday","weekday_name_night_unlang": "Tuesday Night","ampm": "AM","tz": "","age": "","UTCDATE": ""
},
"temp": {"english": "61", "metric": "16"},
"dewpoint": {"english": "56", "metric": "13"},
"condition": "Partly Cloudy",
"icon": "partlycloudy",
"icon_url":"http://icons.wxug.com/i/c/k/partlycloudy.gif",
"fctcode": "2",
"sky": "58",
"wspd": {"english": "7", "metric": "11"},
"wdir": {"dir": "SW", "degrees": "232"},
"wx": "Partly Cloudy",
"uvi": "9",
"humidity": "83",
"windchill": {"english": "-9999", "metric": "-9999"},
"heatindex": {"english": "-9999", "metric": "-9999"},
"feelslike": {"english": "61", "metric": "16"},
"qpf": {"english": "0", "metric": "0"},
"snow": {"english": "0", "metric": "0"},
"pop": "2",
"mslp": {"english": "29.92", "metric": "1013"}
}
It seems to be in an array but when i tried the following it came up with a error of not being a json object.
String row = rootArray.getAsJsonObject().get("sky").getAsString();
** Edit ** I was able to get it to work with the code
String skyText = rootobj.getAsJsonObject().getAsJsonArray("hourly_forecast").get(0).getAsJsonObject().get("sky").getAsString();
with rootobj being my json object