Module that adds support for serialization/deserialization of Kotlin ( classes and data classes.
Switch branches/tags
jackson-module-kotlin-2.9.6 jackson-module-kotlin-2.9.5 jackson-module-kotlin- jackson-module-kotlin-2.9.4 jackson-module-kotlin-2.9.3 jackson-module-kotlin-2.9.2 jackson-module-kotlin-2.9.1 jackson-module-kotlin-2.9.0 jackson-module-kotlin-2.9.0.pr4 jackson-module-kotlin-2.9.0.pr3 jackson-module-kotlin-2.9.0.pr2 jackson-module-kotlin-2.9.0.pr1 jackson-module-kotlin- jackson-module-kotlin-2.8.11 jackson-module-kotlin-2.8.10 jackson-module-kotlin-2.8.9 jackson-module-kotlin-2.8.8 jackson-module-kotlin-2.8.7 jackson-module-kotlin-2.8.6 jackson-module-kotlin-2.8.5 jackson-module-kotlin-2.8.4 jackson-module-kotlin-2.8.3 jackson-module-kotlin-2.8.2 jackson-module-kotlin-2.8.1 jackson-module-kotlin-2.8.0 jackson-module-kotlin-2.8.0.rc2 jackson-module-kotlin-2.8.0.rc1 jackson-module-kotlin- jackson-module-kotlin-2.7.9 jackson-module-kotlin-2.7.8 jackson-module-kotlin-2.7.7 jackson-module-kotlin-2.7.6 jackson-module-kotlin-2.7.5 jackson-module-kotlin-2.7.4 jackson-module-kotlin-2.7.3 jackson-module-kotlin-2.7.2 jackson-module-kotlin-2.7.1 jackson-module-kotlin-2.7.1-2 jackson-module-kotlin-2.7.0 jackson-module-kotlin-2.7.0-rc3 jackson-module-kotlin-2.7.0-rc2 jackson-module-kotlin-2.7.0-rc1 jackson-module-kotlin-2.6.7 jackson-module-kotlin-2.6.6 jackson-module-kotlin-2.6.5 jackson-module-kotlin-2.6.5-2 jackson-module-kotlin-2.6.5-1 jackson-module-kotlin-2.6.4 jackson-module-kotlin-2.6.4-1 jackson-module-kotlin-2.6.3 jackson-module-kotlin-2.6.3-4 jackson-module-kotlin-2.6.3-3 jackson-module-kotlin-2.6.3-2 jackson-module-kotlin-2.6.3-1 jackson-module-kotlin-2.6.2 jackson-module-kotlin-2.6.2-3 jackson-module-kotlin-2.6.2-2 jackson-module-kotlin-2.6.2-1 jackson-module-kotlin-2.6.1 jackson-module-kotlin-2.6.0 jackson-module-kotlin-2.5.5 jackson-module-kotlin-2.5.5-2 jackson-module-kotlin-2.5.5-1 jackson-module-kotlin-2.5.4 jackson-module-kotlin- jackson-module-kotlin-2.5.3 jackson-module-kotlin-2.5.2 jackson-module-kotlin- jackson-module-kotlin-2.5.0 jackson-module-kotlin-2.4.6 jackson-module-kotlin-2.4.5 jackson-module-kotlin-2.4.4 jackson-module-kotlin-2.4.4-1 jackson-module-kotlin-2.4.3 2.5.5-2b 2.5.1b 2.4.3c 2.4.3b
Nothing to show
Clone or download
Latest commit be1aafc Jul 15, 2018
Failed to load latest commit information.
docs/javadoc ... move javadocs over Jul 30, 2017
release-notes prepare for 2.9.6 Jun 12, 2018
src fix Github #131 Jul 15, 2018
.gitattributes ... Apr 5, 2016
.gitignore update to Kotlin M9 Oct 15, 2014
.travis.yml ... Feb 3, 2018 Update Mar 9, 2018
pom.xml not resolvable error github #153 Jul 14, 2018

Kotlin Build Status Kotlin Slack


Module that adds support for serialization/deserialization of Kotlin classes and data classes. Previously a default constructor must have existed on the Kotlin object for Jackson to deserialize into the object. With this module, single constructor classes can be used automatically, and those with secondary constructors or static factories are also supported.


Build Status

Releases are available on Maven Central and these releases are compatible with Kotlin 1.2.x:

  • release (for Jackson 2.9.x)
  • release (for Jackson 2.8.x)
  • release (for Jackson 2.7.x) lacking in some new features from 2.8 branch

Releases require that you have included Kotlin stdlib and reflect libraries already.


compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.+"




For any Kotlin class or data class constructor, the JSON property names will be inferred from the parameters using Kotlin runtime type information.

To use, just register the Kotlin module with your ObjectMapper instance:

val mapper = ObjectMapper().registerModule(KotlinModule())

or with the extension functions imported from import com.fasterxml.jackson.module.kotlin.*, one of:

val mapper = jacksonObjectMapper()
val mapper = ObjectMapper().registerKotlinModule()

A simple data class example:

import com.fasterxml.jackson.module.kotlin.*

data class MyStateObject(val name: String, val age: Int)

val mapper = jacksonObjectMapper()

val state = mapper.readValue<MyStateObject>(json)
// or
val state: MyStateObject = mapper.readValue(json)
// or
myMemberWithType = mapper.readValue(json)

All inferred types for the extension functions carry in full generic information (reified generics). Therefore using readValue() extension without the Class parameter will reify the type and automatically create a TypeReference for Jackson.


You can intermix non-field values in the constructor and JsonProperty annotation in the constructor. Any fields not present in the constructor will be set after the constructor call. An example of these concepts:

   class StateObjectWithPartialFieldsInConstructor(val name: String, @JsonProperty("age") val years: Int)    {
        @JsonProperty("address") lateinit var primaryAddress: String   // set after construction
        var createdDt: DateTime by Delegates.notNull()                // set after construction
        var neverSetProperty: String? = null                          // not in JSON so must be nullable with default

Note that using lateinit or Delegates.notNull() will ensure that the value is never null when read, while letting it be instantiated after the construction of the class.


  • The @JsonCreator annotation is optional unless you have more than one constructor that is valid, or you want to use a static factory method (which also must have platformStatic annotation). In these cases, annotate only one method as JsonCreator.
  • Serializing a member or top-level Kotlin class that implements Iterator requires a workaround, see Issue #4 for easy workarounds.
  • If using proguard, kotlin.Metadata annotations may be stripped, preventing deserialization. Add a proguard rule to keep the kotlin.Metadata class: -keep class kotlin.Metadata { *; }

Support for Kotlin Built-in classes

These Kotlin classes are supported with the following fields for serialization/deserialization (and other fields are hidden that are not relevant):

  • Pair (first, second)
  • Triple (first, second, third)
  • IntRange (start, end)
  • CharRange (start, end)
  • LongRange (start, end)

(others are likely to work, but may not be tuned for Jackson)