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);
}
当我试图编译这段代码时,确实会出现"不兼容类型"错误,尽管这看起来很自然.所以,我的问题是,迭代JSONArray
次的最佳方式是什么?