我使用具有重复密钥的REST COUNTRIES Api
[
{
"name": "Afghanistan",
"topLevelDomain": [
".af"
],
"alpha2Code": "AF",
"alpha3Code": "AFG",
"callingCodes": [
"93"
],
},
{
"name": "Åland Islands",
"topLevelDomain": [
".ax"
],
"alpha2Code": "AX",
"alpha3Code": "ALA",
"callingCodes": [
"358"
],
],
我尝试获取所有国家/地区的名称(键“名称”) 如何从所有重复键中获取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()
}
}