I've been using both JSONObject and JSONReader, but ideally I'm looking for a hybrid :)
In particular, given a stream of JSON objects, part of arbitrarily long JSON array, is there a helper/library that yields "JSONObject" at a time, iterator style, instead of reading everything in or having to parse out individual primitive fields (JsonReader)?
Example of hypothetical API:
JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));reader.beginArray();while (reader.hasNext()) { JSONObject obj = reader.readObject(); // do something with 'obj'}reader.endArray();
Above, calling readObject parses some complex JSON sub-tree and returns it as JSONObject.