Я получаю эту ошибку, когда пытаюсь получить массив json из JSONObject ArrivedResult
.
Вот мой JSON:
{
"ArrivedResult": {
"arrivals": [
{
"ident": "MSR637",
"aircrafttype": "A321",
"actualdeparturetime": 1541399820,
"actualarrivaltime": 1541406652,
"origin": "HECA"
}
]
}
}
мой код
private fun handleJson(jsonString: String?) {
val jsonObj = JSONObject(jsonString)
val ArrivedResult = jsonObj.getJSONObject("ArrivedResult")
val jsonArray = JSONArray(ArrivedResult.get("arrivals").toString())
val list = ArrayList<FlightShdu>()
var x = 0
while (x < jsonArray.length()) {
val jsonObject = jsonArray.getJSONObject(x)
list.add(FlightShdu(
jsonObject.getString("aircrafttype"),
jsonObject.getString("destination")
))
x++
}
}
Я получил ошибку Caused by: org.json.JSONException: No value for ArrivedResult