JEP 198: Light-Weight JSON API

Remi Forax forax at
Thu Jul 31 00:35:00 UTC 2014

On 07/25/2014 04:45 PM, mark.reinhold at wrote:
> New JEP Candidate:
> - Mark

Hi Mark, Hi Mike,
Implementing a json API was one of the use case I've used during the 
development of the lambdas,
so maybe you are interested by this gist
which implement a Json API in one file (just for fun).
(the implementation requires a parser that implement the JSON 
processing/streaming API, writing a new lightweight JSON parser was not 
my concern :) at that time)
At the end of the file, there is a main with several examples.

The idea is to have a couple of interface (ObjectVisitor and 
ArrayVisitor) that represent a lazy visit of a JSON tree,
that can reify a portion of the tree either using Map/Stream* objects or 
using JsonObject/JsonArray objects or that can just skip a part of the 
tree which is not necessary.
* JSON array are viewed as Stream so the parsing is triggered by the 
terminal operation done on the Stream.

The interfaces are maybe a little over-designed (you can also skip 
primitive values by example) but like the Collector API,
i like the idea that you have one API that let you just plug any tree 
representation you want.


More information about the core-libs-dev mailing list