I'm getting this exception error when using the OpenWeatherMap API. I'm just trying to get the result to be an JSONObject, but null keeps coming up.
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
// What's coming in as result...
// Printed to the console...
// null{"coord":{"lon":-0.13,"lat":51.51},"weather":[{"id":800,"main":"Clear",
// "description":"clear sky","icon":"01d"}],...}
try {
JSONObject jsonObject = new JSONObject(result);
String weatherInfo = jsonObject.getString("weather");
Log.i("Weather Info", weatherInfo);
} catch (JSONException e) {
e.printStackTrace();
}
}
The JSON data comes in fine but all I want is it to become a JSONObject but the null part is catching. Any Ideas why that might be happening?
Also from the site the JSON Response
coming in is:
{"coord":{"lon":-0.13,"lat":51.51},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],.....}
How come that doesn't have null at the start? Thank you for your help.