Я использую REST COUNTRIES Api с дублирующимися ключами
[
{
"name": "Afghanistan",
"topLevelDomain": [
".af"
],
"alpha2Code": "AF",
"alpha3Code": "AFG",
"callingCodes": [
"93"
],
},
{
"name": "Åland Islands",
"topLevelDomain": [
".ax"
],
"alpha2Code": "AX",
"alpha3Code": "ALA",
"callingCodes": [
"358"
],
],
Я пытаюсь получить имена всех стран (ключ "name"), как получить json значение объекта из всех дубликатов ключа?
override fun onProgressUpdate(values: Array<String?>) {
try {
val jsonArray = JSONArray(values[0])
for (allCountries in 0 until jsonArray.length() ){
val jsonAllCountriesData = jsonArray.getJSONObject(allCountries)
println("jsonCountriesData == $jsonAllCountriesData ")
}
}catch (e:Exception){
e.printStackTrace()
}
}