1
1
101-s2019-02-04 00:41:05
Java
101-s, 2019-02-04 00:41:05

How to iterate over JSON in JAVA?

There is a JSON like

{"8704": {"model":"XXX","cat":115},
"8700": {"model":"YYY","cat":112},
...
}

the string "8704":{"model":"XXX","cat":115} is defined as a hash map
How to iterate over this array with normal JAVA tools
and make a list [8704, "XXX", 115], [], ... ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EVGENY T., 2019-02-04
@101-s

The JSONArray and JSONObject classes will help you.
We get an array of objects using getJasonArray(), individual objects - using getJSONObject(), the values ​​themselves - getString().
Good luck!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question