A small JSON parsing library

Remi Forax forax at univ-mlv.fr
Thu Feb 14 07:53:23 PST 2013

Hi all,
just to see how it goes, I've written a small all-in-one-file library 
that parses a JSON files to an object tree defined by the user. The 
mapping is specified using lambdas, so it's compact but can burn your 
eyes :)


The idea is that the JSON parser is triggered by the consumption of the 
corresponding stream,
so when the code do by example a forEach on a Stream, the parser parse 
the corresponding objects.
I've used an already existing push parser named json-simple for that.

During the development, I've found two main gotchas,
the first one is the scope rules of the lambda parameter,
I've already sent message about this rule, it seems that eah time I 
write a page of code, the compiler stop me because I tend to re-use the 
same variable name for the very same object.
In the example named Big [1], the builder of JSON schema is used 
recursively but I've to use a different names each time (builder, 
builder2, builder3).
We should really remove this stupid rule from the JLS and go back to the 
classical shadowing rules.

The second problem is that the implementation uses method handles to but 
due to the poor integration betweeen method handles and lambdas, I've 20 
lines of boilerplate and error prone code [2] which is moreover executed 
too eagerly.


[1] https://github.com/forax/jsonjedi/blob/master/src/Big.java

More information about the lambda-libs-spec-observers mailing list