A
A
Anton Osipov2016-09-10 23:01:16
Java
Anton Osipov, 2016-09-10 23:01:16

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

1 answer(s)
A
Artem Vishnevsky, 2016-09-16
@tohaosipow

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 question

Ask a Question

731 491 924 answers to any question