Android Jetpack Benchmark: JSON Parser Performance
Article Summary
Mootaz Ltaief from OLX Engineering put four popular Android JSON parsers head-to-head using Jetpack Benchmark. The results reveal a brutal tradeoff: the fastest parser costs you 1.1 MB of app size.
When OLX slashed their Android app from 23 MB to 11 MB, they discovered Jackson was consuming 1.1 MB alone. This sparked a systematic benchmark of Gson, Moshi, Jackson, and Kotlinx.Serialization using Google's new Benchmark library on a lower-end Huawei Y7 device representing their core userbase.
Key Takeaways
- Jackson wins on speed but adds 1.1 MB and 10k+ methods to your APK
- Kotlinx.Serialization runs nearly as fast with much smaller footprint
- Moshi is tiniest at 82 KB but slowest on complex JSON payloads
- Performance gaps widen dramatically on lower-end devices with complex responses
For Android apps targeting emerging markets or size-conscious builds, Kotlinx.Serialization offers the best balance of speed and footprint, running close to Jackson's performance at a fraction of the size cost.
About This Article
OLX's Android app grew to 23 MB even after optimization attempts. The Jackson library alone took up 1.1 MB, and the compiled APK contained over 10,000 methods.
Mootaz Ltaief tested four JSON serialization libraries using Google's Jetpack Benchmark library (v1.0.0-alpha02). The tests ran on a Huawei Y7 device with Android 7.0 to measure both speed and file size.
Kotlinx.Serialization matched Jackson's performance while using much less space. This let OLX shrink the app size without losing parsing speed on lower-end devices.