Quantcast
Channel: Working with JSON streams efficiently (in Java) - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Working with JSON streams efficiently (in Java)

$
0
0

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.


Viewing all articles
Browse latest Browse all 2

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>