Answer the question
In order to leave comments, you need to log in
Json Java Android how to parse?
Please tell me how to parse this JSON. To get elements [0], [1] because they don't have a string binding binding and can't getJSONObject().
Array
(
[Date] => 12.09
[Timetable] => Array
(
[0] => Array
(
[SubjectName] => Math
[SubjectTime] => 8:30 - 9:10
)
[1] => Array
(
[SubjectName ] => Russian
[SubjectTime] => 8:30 - 9:10
)
[2] => Array
(
[SubjectName] => Lit.reading
[SubjectTime] => 8:30 - 9:10
)
[3] => array
(
[SubjectName] => Technology
[SubjectTime] => 8:30 - 9:10
)
[4] => Array
(
[SubjectName] => English
[SubjectTime] => 8:30 - 9:10
)
)
)
Answer the question
In order to leave comments, you need to log in
You have a strange looking Json, of course =) Use JSONArray to access array elements, e.g.:
// Ваш JSON текст
String json = "";
// Парсим текст в JSONObject
JSONObject obj = new JSONObject(json);
// Получаем массив объектов JSON
JSONArray arr = obj.getJSONArray("Timetable");
// Обходим массив в цикле
for(int i = 0; i < arr.length(); i++){
JSONObject element = arr.get(i);
// Делаем необходимые действия с элементом
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question