Disclaimer: This is NOT an attempt to evaluate all aspects of either piece of technology. I used a specific use case that is applicable to my needs, and ran the comparison. Your specific use case may differ.
In my use case, I took a very simple object (User with an associated Address object) and converted it to a JSON String (and back) in a varying number of loops using the respective JSON library.
In my first run-through, I created an instance of the respective JSON library in each iteration of the loop. This proved to cause a HUGE discrepancy in favour of GSON:
Here is the raw data:
10 | 109 | 3 | 11 | 5 |
100 | 519 | 32 | 88 | 37 |
1000 | 1439 | 108 | 398 | 199 |
10000 | 6178 | 361 | 967 | 477 |
100000 | 52795 | 474 | 4851 | 1388 |
1000000 | 525179 | 3779 | 49100 | 10966 |
Conclusion:
If your project will be creating an instance of the JSON library on the fly, it would be better to use GSON. However, if you have an instance of the library already created, Jackson proves to be faster. As my project is using Spring, it is beneficial to use Jackson, and instantiate the ObjectMapper in the Spring context.