I have the following JSON and I would like to parse all of the "vcsapat" and "hcsapat" and all of the datas from the first rows.
Json is here:Link
I tried with the following code, but I only have exceptions
JSONArray JSonAdatok = null;
JSonAdatok = jObject.getJSONArray("vcsapat");
for (int i = 0; i < JSonAdatok.length(); i++) {
JSONObject jo = null;
try {
jo = JSonAdatok.getJSONObject(i);
System.out.print("\n"+jo);
JSONObject kezdojatekosok = jo.getJSONObject("kezdo");
System.out.print("\n"+kezdojatekosok);
for (int j = 0; j < kezdojatekosok.length(); j++) {
JSONObject egyjjson = kezdojatekosok;
And the Exception is the following:
at org.json.JSON.typeMismatch(JSON.java:100)
org.json.JSONObject.getJSONArray(JSONObject.java:588)
Your JSON contains first an Object which starts with "{" so your whole JSON string represents an JSONObject. Then after, get inside it the object "hforma" then the JSONArray of forma, and then you can iterate on them to get on each the hcsapat and vcsapat attributes as strings.
Something like this:
I did not test that code, it is just an example that follows the structure of your JSON.