I got to the desired:

enter image description here

Did this:

val result = JSONObject(data) .getJSONObject("response") .getJSONObject("GeoObjectCollection") .getJSONArray("featureMember") .getJSONObject(0) .getJSONObject("GeoObject") adr.text = result.getString("name") 

Everything works, but even embarrassing ... looks strange. Do I need to somehow humanize this business, or so come down?

  • one
    The code corresponds to the data structure, you can hide it in the extension function. - Eugene Krivenja

2 answers 2

Look in the direction of the Retrofit and to it, let's say the converter GSON .

  • one
    Gson can be used by itself, if that. - Eugene Krivenja
  • True, I did not use Retrofit + GSON, but Retrofit + Moshi (Josh library for Kotlin. It understands Kotlin's non-nullable types and default parameter values.). And the Kotlin Coroutine Adapter (call). - iFr0z am

If you want to be more beautiful and you often parse the json code, look at some library. In the cotlin not sure what is, in java yuzal Gson, Jackson