On 07/25/2014 04:45 PM, [email protected] wrote:
New JEP Candidate: http://openjdk.java.net/jeps/198

- 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
  https://gist.github.com/forax/81a56cf2684bfa2e46ec
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.

cheers,
Rémi

Reply via email to