Is there a faster Jackson alternative for parsing JSON in Kotlin?
n
Is there a faster Jackson alternative for parsing JSON in Kotlin?
c
This article is specific to Android, but it has benchmarks for several parsers https://medium.com/stanwood/save-my-ass-benchmark-of-json-deserializers-on-android-28341c1e82df
h
Jackson already is one of the fastest… But check out https://github.com/fabienrenaud/java-json-benchmark – maybe
jsoniter
or
dsl-json
are what you want.
l
kotlinx.serialization is a nice one. Fast at compile and runtime, and supports Protobuf, which is lighter than JSON if you want to make meaningful performance improvements, as network payload is often more expensive that (de)serialization.
d
If you're looking for a performance improvement and not just library change, you can write a streaming parser using Jackson, or find a tool that will generate the parser for you. When I ran into JSON performance issues a couple of years ago, the streaming parser was about 3x faster than the regular reflective one with my test configuration. (I used a library to generate the parser called LoganSquare but I'm not sure if it's still maintained)
m
moshi generates streaming adapters for your objects in compile-time, so no reflection at runtime. That makes it quite fast.
Not sure how kotlinx.serialization works though
n
Thanks all!
247 Views