If you want to turn a JSON file into a java.util.Map, it appears that Boon is the fastest option. When I first read the article, this was not the case. I had some ideas for speeding up the JSON parsing, but never seemed to need to (it seemed fast enough). Then this article came out, http://www.infoq.com/articles/HIgh-Performance-Parsers-in-Java.
I downloaded the source for the benchmark, and ran the benchmarks.
Then I tweaked Boon JSON parser to be faster than GSON.
I also improved compliance testing of the Boon parser, and was able to tweak performance by 20x to 25x for Boon parser.
Then I added the performance enhancements that I dreamed about, but never implemented.
It appears it is now faster than Jackson and GSON for the use case of turning a JSON string into a java.util.Map.
Boon allows turning a map into a Java object so it can do object serializaiton of JSON, but you have to first convert JSON into Map and then Map into Object.
I have not performance tuned full Object serialization this and I am sure GSON and Jackson must be faster. Boon plans on supporting this so the plan is for it be very fast if not the fastest (eventually).
But tune in later for more benchmarks.
For now, it is just the fastest at serialization to a map.
Boon does not plan on being a pull parser or a tree parser or a event parser... ever. Boon does JSON but not all the ins and outs. If you want a pull parser, use Jackson or GSON. If you want a tree view parser, use Jackson or GSON.
Boon is optimized for REST calls and Websocket messages. It is not a generic JSON parser. I don't want it to be. I don't care.
A set of JSON parser benchmarks.
Using json.org/examples (http://json.org/example) as a guide:
testing actionLabel.json BOON 1 PASSED actionLabel.json BOON 2 PASSED actionLabel.json GSON # PASSED actionLabel.json INFO Q FAILED actionLabel.json JACK 1 PASSED actionLabel.json testing menu.json BOON 1 PASSED menu.json BOON 2 PASSED menu.json GSON # PASSED menu.json INFO Q FAILED menu.json JACK 1 PASSED menu.json testing sgml.json BOON 1 PASSED sgml.json BOON 2 PASSED sgml.json GSON # PASSED sgml.json INFO Q FAILED sgml.json JACK 1 PASSED sgml.json testing webxml.json BOON 1 PASSED webxml.json BOON 2 PASSED webxml.json GSON # PASSED webxml.json INFO Q FAILED webxml.json JACK 1 PASSED webxml.json testing widget.json BOON 1 PASSED widget.json BOON 2 PASSED widget.json GSON # PASSED widget.json INFO Q FAILED widget.json JACK 1 PASSED widget.json
For background, read this article on how to write fast parsers.
Parse times for small json 10,000,000 runs:
GSON: 8,334 mili second JACKSON: 7,156 Boon 2: 2,645 Boon 1: 3,799 InfoQ : 11,431
Smaller is better.
The slowest parser was the one from the article on how to write fast parser. I make mistakes too so no harm, no foul. It is still an interesting article and has good ideas. Boon 2 is 3x faster than Jackson for this use case. Boon 1 is almost 2x faster then Jackson for this use case.
Parse times for large json file 1,000,000 runs:
Boon 2: 15,543 mili second Boon 1: 19,967 JACKSON: 18,985 InfoQ: ParserException GSON: 25,870
Lower is better. It should be noted that Boon 1 was taking 200+ seconds when I first ran this test. I had to make some changes to get Boon 1 to this level. It was actually one small change. ;) I love profilers.
Here is the JSON for the small json file (large JSON file is below):
Source code for benchmark tests:
Source code for large test:
Large json file from json.org examples
I am not sure what a micro benchmark is, and this benchmark might not be completely fair. Please let me know how to improve it.