I'm sure this is asked plenty and i've found some questions on here similar but none really got solve my problem. I'm hoping someone can help me out.
What I want to do is present the user with a dropdown (spinner) with a list of city. And in the list of city have a sublist. The list and sublist is from JSON.
User users can only selected sub list.
This my JSON:
{
"data":{
"City":[
{
"city_id":112,
"name":"Jakarta",
"school":[
{
"school_id":1,
"parent":112,
"school":"Junior 1"
},
{
"school_id":2,
"parent":112,
"school":"Junior 2"
}
]
},
{
"city_id":113,
"name":"Jakarta",
"school":[
{
"school_id":3,
"parent":113,
"school":"High 1"
}
]
}
]
}
}
this my parsing code :
for (int i=0; i<city.length();i++){
JSONObject listcity = city.getJSONObject(i);
JSONArray school = listcity.getJSONArray("school");
for (int j=0; j<school.length(); j++){
JSONObject listschool = school.getJSONObject(j);
VolleyLog.e("List Desa =======>"+listschool);
}
}
expected output :
Jakarta
- Junior 1
- junior 2
Tokyo
- High 1
So far i have been parsing JSON data, I would appreciate if anyone could show the solution of the described problem or provide any link useful to solve the problem.
Thanks!