I've been reading about how jackson is the fastest json parser. And I wanted to know what exactly that meant.
I've used gson in the past and have never had a problem wth the speed of it, but I've never been in a situation where every bit of speed counts.
I devised a simple test. Using junit.
Serialize the same object 100 times with each gson and jackson and time how long it takes.
gson is between 150 and 200 ms for my object every time.
jackson is between 670 and 720 ms for my object every time.
Clearly here gson is the winner. However, I wanted to make sure I didn't sell jackson short, maybe it excels in another area.
Serialize both with gson and jackson in the same unit test with gson first in case object creation matters.
gson is between 150 and 200 ms every time.
jackson is between 620 and 680 ms all but one time which was 901 ms.
Serialize both with gson and jackson in the same unit test with jackson first in case object creation matters.
gson is between 120and 170 ms every time.
jackson is between 589 and 700 ms every time.
Finally I decided if I'm using it in a web service I'll need to create POJOs from the JSON for processing if there is a post.
Build POJO from JSON
gson is between 103 and 141 ms every time.
jackson is between 469 and 546 ms every time.
An interesting thing I found is that the object I was dealing with had a Calendar in it. This serializes and deserializes just fine in jackson, but in gson it would create a nice output, but did not populate the POJO correctly. When I changed it to a Date object both Jackson and gson worked correctly.
My final review is that clearly gson is faster than Jackson. In it's worst case and Jackson's best case gson is still always twice as fast. I had used gson, just because I found it easy to use, but now that I have run some benchmarks I know I happened to get lucky enough to find the faster library.