Answer the question
In order to leave comments, you need to log in
How to parse nested JSON objects?
There is json data in the file https://www.cbr-xml-daily.ru/daily_json.js , they are received and processed:
val data = response.toString()
val valute = JSONObject(data).getJSONObject("Valute")
println(valute.toString())
{
"Date": "2022-02-12T11:30:00+03:00",
"PreviousDate": "2022-02-11T11:30:00+03:00",
"PreviousURL": "\/\/www.cbr-xml-daily.ru\/archive\/2022\/02\/11\/daily_json.js",
"Timestamp": "2022-02-13T23:00:00+03:00",
"Valute": {
"AUD": {
"ID": "R01010",
"NumCode": "036",
"CharCode": "AUD",
"Nominal": 1,
"Name": "Австралийский доллар",
"Value": 53.5105,
"Previous": 53.7266
},
...
{
"AUD": {
"ID": "R01010",
"NumCode": "036",
"CharCode": "AUD",
"Nominal": 1,
"Name": "Австралийский доллар",
"Value": 53.5105,
"Previous": 53.7266
},
...
"ID" "NumCode" "CharCode" "Nominal" "Name" "Value" "Previous"
AUD "R01010" "036" "AUD" 1 "Австралийский доллар" 53.5105 53.7266
AZN ...
GBP ...
Answer the question
In order to leave comments, you need to log in
And who is stopping you from getting objects further?
val aud = value.getJSONObject("AUD")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question