I'm using org.json.simple.JSONArray
and org.json.simple.JSONObject
. I know that these two classes JSONArray
and JSONObject
are incompatible, but still I want to do quite a natural thing - I want to for-each over JSONArray
parsing at each iteration step one JSONObject
(nested inside that JSONArray
). I try to do it like so:
JSONArray arr = ...; // <-- got by some procedure
for(JSONObject o: arr){
parse(o);
}
When I try to compile this code, indeed I get "incompatible types" error, even though it looks so natural. So, my question is what is the best way to iterate through JSONArray
?