You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+64-21Lines changed: 64 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -2,23 +2,28 @@
2
2
3
3
# Overview
4
4
5
-
Module that adds support for serialization/deserialization of [Kotlin](http://kotlinlang.org) 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.
5
+
Module that adds support for serialization/deserialization of [Kotlin](http://kotlinlang.org)
6
+
classes and data classes.
7
+
Previously a default constructor must have existed on the Kotlin object for Jackson to deserialize into the object.
8
+
With this module, single constructor classes can be used automatically,
9
+
and those with secondary constructors or static factories are also supported.
6
10
7
11
# Status
8
12
9
-
2.9.8+ Releases are compiled with Kotlin 1.3.x, other older releases are Kotlin 1.2.x. All should be compatible with
10
-
current Kotlin if you also ensure the `kotlin-reflect` dependency is included with the same version number as stdlib.
13
+
2.9.8+ Releases are compiled with Kotlin 1.3.x, other older releases are Kotlin 1.2.x.
14
+
All should be compatible with current Kotlin if you also ensure the `kotlin-reflect`
15
+
dependency is included with the same version number as stdlib.
11
16
12
-
* release `2.12` (for Jackson `2.12.x`) [](https://circleci.com/gh/FasterXML/jackson-module-kotlin/tree/2.12)
13
-
* release `2.11.2` (for Jackson `2.11.x`) [](https://circleci.com/gh/FasterXML/jackson-module-kotlin/tree/2.11)
17
+
* release `2.12.0` (for Jackson `2.12.x`) [](https://circleci.com/gh/FasterXML/jackson-module-kotlin/tree/2.12)
18
+
* release `2.11.4` (for Jackson `2.11.x`) [](https://circleci.com/gh/FasterXML/jackson-module-kotlin/tree/2.11)
14
19
* release `2.10.5` (for Jackson `2.10.x`)
15
20
* release `2.9.10` (for Jackson `2.9.x`)
16
21
17
22
Releases require that you have included Kotlin stdlib and reflect libraries already.
All inferred types for the extension functions carry in full generic information (reified generics).
78
-
Therefore, using `readValue()` extension without the `Class` parameter will reify the type and
79
-
automatically create a `TypeReference` for Jackson.
83
+
Therefore, using `readValue()` extension without the `Class` parameter will reify the type and automatically create a `TypeReference` for Jackson.
80
84
81
85
# Annotations
82
86
@@ -93,18 +97,20 @@ An example of these concepts:
93
97
}
94
98
```
95
99
96
-
Note that using `lateinit` or `Delegates.notNull()` will ensure that the value is never null when read,
97
-
while letting it be instantiated after the construction of the class.
100
+
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.
98
101
99
102
# Caveats
100
103
101
104
* 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, e.g. `@JvmStatic`). In these cases, annotate only one method as `JsonCreator`.
102
105
* Serializing a member or top-level Kotlin class that implements Iterator requires a workaround, see [Issue #4](https://github.com/FasterXML/jackson-module-kotlin/issues/4) for easy workarounds.
103
-
* 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 { *; }`
106
+
* If using proguard:
107
+
*`kotlin.Metadata` annotations may be stripped, preventing deserialization. Add a proguard rule to keep the `kotlin.Metadata` class: `-keep class kotlin.Metadata { *; }`
108
+
* If you're getting `java.lang.ExceptionInInitializerError`, you may also need: `-keep class kotlin.reflect.** { *; }`
104
109
105
110
# Support for Kotlin Built-in classes
106
111
107
-
These Kotlin classes are supported with the following fields for serialization/deserialization (and other fields are hidden that are not relevant):
112
+
These Kotlin classes are supported with the following fields for serialization/deserialization
113
+
(and other fields are hidden that are not relevant):
108
114
109
115
* Pair _(first, second)_
110
116
* Triple _(first, second, third)_
@@ -116,22 +122,18 @@ These Kotlin classes are supported with the following fields for serialization/d
116
122
117
123
# Configuration
118
124
119
-
The Kotlin module may be given a few configuration parameters at construction time; see the [inline documentation](https://github.com/FasterXML/jackson-module-kotlin/blob/master/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt) for details on what options are available and what they do.
125
+
The Kotlin module may be given a few configuration parameters at construction time;
126
+
see the [inline documentation](https://github.com/FasterXML/jackson-module-kotlin/blob/master/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt)
127
+
for details on what options are available and what they do.
120
128
121
129
```kotlin
122
130
val mapper =JsonMapper.builder()
123
131
.addModule(KotlinModule(strictNullChecks =true))
124
132
.build()
125
-
126
-
// Or, from version 2.12
127
-
val mapper = jsonMapper {
128
-
addModule(kotlinModule {
129
-
strictNullChecks(true)
130
-
})
131
-
}
132
133
```
133
134
134
-
If your `ObjectMapper` is constructed in Java, there is a builder method provided for configuring these options:
135
+
If your `ObjectMapper` is constructed in Java, there is a builder method
Following developers have committer access to this project.
152
+
153
+
* Author: Jayson Minard (@apatrida) wrote this module; still helps issues from time to time
154
+
* Active Maintainers:
155
+
* Drew Stephens (@dinomite)
156
+
* Vyacheslav Artemyev (@viartemev)
157
+
* Co-maintainers:
158
+
* Tatu Saloranta (@cowtowncoder)
159
+
160
+
You may at-reference them as necessary but please keep in mind that all
161
+
maintenance work is strictly voluntary (no one gets paid to work on this
162
+
or any other Jackson components) so there is no guarantee for timeliness of
163
+
responses.
164
+
165
+
All Pull Requests should be reviewed by at least one of active maintainers;
166
+
bigger architectural/design questions should be agreed upon by majority of
167
+
active maintainers (at this point meaning both Drew and Vyacheslav :) ).
168
+
169
+
## Releases & Branches
170
+
171
+
This module follows the release schedule of the rest of Jackson—the current version is consistent
172
+
across all Jackson components & modules. See the [jackson-databind README](https://github.com/FasterXML/jackson#actively-developed-versions) for details.
173
+
174
+
## Contributing
175
+
176
+
We welcome any contributions—reports of issues, ideas for enhancements, and pull requests related to either of those.
177
+
178
+
See the [main Jackson contribution guidlines](https://github.com/FasterXML/jackson/blob/master/CONTRIBUTING.md) for more details.
179
+
180
+
### Branches
181
+
182
+
If you are going to write code, choose the appropriate base branch:
183
+
184
+
-`2.12` for bugfixes against the current stable version
185
+
-`2.13` for additive functionality & features or [minor](https://semver.org), backwards compatible changes to existing behavior to be included in the next minor version release
186
+
-`master` for significant changes to existing behavior, which will be part of Jackson 3.0
0 commit comments