Before I get started, could I just point out I've spent the last 5 hours going in circles here. I've tried what seems like every StackOverflow method out there to pull what seems like a simple int from an API. This seems like it should be way easier, but isn't.
What I'm trying to achieve is pull the JSON info from this URL:
http://api.apixu.com/v1/current.json?key=ENTERKEYHERE&q=leeds
And then gather the category "temp_c", which should be something along the lines of "7.0". Below is an example of how a call looks:
{
"location": {
"name": "Leeds",
"region": "West Yorkshire",
"country": "United Kingdom",
"lat": 53.81,
"lon": -1.54,
"tz_id": "Europe/London",
"localtime_epoch": 1509670055,
"localtime": "2017-11-03 0:47"
},
"current": {
"last_updated_epoch": 1509669008,
"last_updated": "2017-11-03 00:30",
"temp_c": 7,
"temp_f": 44.6,
"is_day": 0,
"condition": {
"text": "Partly cloudy",
"icon": "//cdn.apixu.com/weather/64x64/night/116.png",
"code": 1003
},
"wind_mph": 4.3,
"wind_kph": 6.8,
"wind_degree": 150,
"wind_dir": "SSE",
"pressure_mb": 1015,
"pressure_in": 30.4,
"precip_mm": 0,
"precip_in": 0,
"humidity": 93,
"cloud": 75,
"feelslike_c": 5.8,
"feelslike_f": 42.4,
"vis_km": 10,
"vis_miles": 6
}
}
I've successfully gotten the data to pull into an app during random points in the night, however have been unable to pull the specific piece of data at all. Currently, my app won't pull it at all and I'm not sure what I did before.
I'm truly sorry if this is a question deemed "duplicate", but I can assure you that for someone trying to learn the language, none of the answers fully explain how to do this using the newer API's (Some of the answers seem to no longer work in API 23+)
I'm not looking for a detailed app with loads of methods, just a simple way of pulling the JSON data and selecting a specific category. I'd be extremely grateful if you could explain how to do this as I plan on adapting the code in the future for other sources. Thank you!