JSON raw data sample : result(String) =
{
"temp": {
"min":11.34,
"max":19.01
},
"weather": {
"id":801,
"condition":"Clouds",
"description":"few clouds"
},
"pressure":1023.51,
"humidity":87
}
Code to Parse:
try {
val forecast = JSONObject(result!!)
val weather = forecast.getJSONObject("weather")
Log.d(TAG, weather.getString("condition"))
}catch (e:Exception){
e.printStackTrace()
}
Comments
Post a Comment