Participants:
- Boon
- Circe
- DSL-JSON
- Fastjson
- Genson
- Gson
- Jackson
- Jackson-afterburner
- JSR 353 Glassfish (javax.json)
- json.org
- Json-iterator
- Json-simple
- Klaxon
- Kotlinx.serialization
- Mjson
- Minimal-json
- Moshi
- Tools-json
For testing were selected data with different structure:
- citys - A large array (29470 items) of simple objects. The compact json representation takes about 2.5 MB. Main challenge: floating point numbers
- repos.json - An array of four objects with complex structure. The compact json representation takes about 342.8 kB. Main challenge: a lot of String fields
- user.json - one object with a complex structure. The compact json representation takes about 4.2 kB. Main challenge: dates
- request.json - one object with a simple structure. The compact json representation takes about 425 B. Main challenge: Maps of Strings, small json
Serialization and deserialization were tested with POJO and Map-like structures
./gradlew clean && ./gradlew shadowJar && java -jar build/libs/json-benchmarks-all.jar ".*Benchmarks.*"
# or individual benchmarks
./gradlew clean && ./gradlew shadowJar && java -jar build/libs/json-benchmarks-all.jar ".(Des|S)erializationBenchmarks.(pojo|map)_(dslplatform|tools|kotlinx|jsonIterator|klaxon).*"
Very different results for boon deserialization into maps and pojos looked suspicious for me, so I've made another benchmark: 'deserialize into map' vs 'deserialize into map and get value of one field' and compared it with Tools and pojos.
As I expected, Boon uses lazy maps and creates actual values only when requested