I have just started learning Kotlin and I have a problem. I want to make an API request to get weather data from openweathermap.org, but I don't know how to access all of the values inside the response body.
Example of API response:
Here is the code I have so far:
override fun onResponse(call: Call, response: Response) {
val body = JSONObject(response.body?.string())
findViewById<TextView>(R.id.weatherDescription).text = body.get("weather")
}
But I would like to get the weather Description for example, but I cant do this:
body.get("weather")[0].get("description")
So my question is, how I can access all these values.
Thanks for help in advance!