dvlwj
01/16/2019, 5:42 PM{
"status": 1,
"msg": "List",
"kelas": [
{
"id": 1,
"name": "1A"
},
{
"id": 2,
"name": "2A"
},
{
"id": 3,
"name": "3A"
},
{
"id": 4,
"name": "4A"
},
{
"id": 5,
"name": "5A"
},
{
"id": 6,
"name": "6A"
}
]
}
and i already parse it with this class :
class Status(val status: Int)
class DataKelas(val status: Int, val kelas: Kelas)
class Kelas(val id: Int, val name: String)
I do it like this :
val respond = respond_from_httprequest
val respondData = Klaxon().parse<Status>(respond)
when(respondData?.status){
1 -> {
val json = Klaxon().parse<DataKelas>(respond)
// I doesn't have any idea what to do here
}
}
what i need to do to parse the value of Kelas
? I know usually we can do it just with json.kelas.id
and json.kelas.name
, but i need it to be an array with full data in it, because i want to make it as value of my spinner.
I already read the documentation, but i think i have a confused mind right now.