Back to feed
Dev.to
Dev.to
7/4/2026
How to deal with empty lists that defaults to null in Jackson and Kotlin

How to deal with empty lists that defaults to null in Jackson and Kotlin

Short summary

Jackson with Kotlin throws null assertion errors when deserializing JSON payloads containing empty lists configured to default to null. The fix is to configure KotlinModule with NullIsSameAsDefault set to true, which directs Jackson to treat empty collections as default values rather than null during the deserialization process. Add the jackson-module-kotlin:2.17.+ dependency, register the custom KotlinModule in your ObjectMapper using KotlinModule.Builder(), and the issue is immediately resolved.

  • Jackson throws null assertion errors on empty Kotlin lists with null defaults
  • Configure KotlinModule.Builder() with NullIsSameAsDefault=true
  • Add jackson-module-kotlin:2.17.+ and register custom ObjectMapper for immediate fix

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Comments

Failed to load comments. Please try again.

Explore more