I have used Anko to get a JSON in Kotlin and it works well but I do not know how can I access to each value.
I have this code which prints out the whole JSON:
doAsync {
val result = URL("url.json").readText()
uiThread {
longToast(result)
}
}
So now that I have the whole JSON, how can I access to each field?
I have tried with result[0].toString()and result.get(0).toString() but it did not work because it prints out the first character of result which is [
Use
JSONArrayandJSONObjectto parse json like below.In Java:
In Kotlin: