File tree 4 files changed +17
-26
lines changed
src/main/kotlin/com/fasterxml/jackson/module/kotlin
4 files changed +17
-26
lines changed Original file line number Diff line number Diff line change @@ -55,28 +55,8 @@ val mapper = jsonMapper {
55
55
}
56
56
```
57
57
58
- <details >
59
- <summary >Jackson versions prior to 2.10–2.11</summary >
60
-
61
- ``` kotlin
62
- import com.fasterxml.jackson.databind.json.JsonMapper
63
- import com.fasterxml.jackson.module.kotlin.KotlinModule
64
- .. .
65
- val mapper = JsonMapper .builder().addModule(KotlinModule ()).build()
66
- ```
67
- </details >
68
-
69
-
70
- <details >
71
- <summary >Jackson versions prior to 2.10</summary >
72
-
73
- ``` kotlin
74
- import com.fasterxml.jackson.databind.ObjectMapper
75
- import com.fasterxml.jackson.module.kotlin.KotlinModule
76
- .. .
77
- val mapper = ObjectMapper ().registerModule(KotlinModule ())
78
- ```
79
- </details >
58
+ In 2.17 and later, the ` jacksonObjectMapper {} ` and ` registerKotlinModule {} ` lambdas allow configuration for ` KotlinModule ` .
59
+ See [ #Configuration] ( #Configuration ) for details on the available configuration items.
80
60
81
61
A simple data class example:
82
62
``` kotlin
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ Contributors:
18
18
# 2 .17.0 (not yet released)
19
19
20
20
WrongWrong (@k163377 )
21
+ * #741 : Changed to allow KotlinFeature to be set in the function that registers a KotlinModule.
21
22
* #740 : Reduce conversion cache from Executable to KFunction.
22
23
* #738 : Fix JacksonInject priority.
23
24
* #732 : SequenceSerializer removed.
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ Co-maintainers:
18
18
19
19
2.17 .0 (not yet released )
20
20
21
+ #741 : Changed to allow KotlinFeature to be set in the function that registers a KotlinModule .
22
+ The `jacksonObjectMapper {}` and `registerKotlinModule {}` lambdas allow configuration for KotlinModule .
21
23
#740 : Reduce conversion cache from Executable to KFunction.
22
24
This will reduce memory usage efficiency and total memory consumption , but may result in a minor performance degradation in use cases where a large number of factory functions are used as JsonCreator .
23
25
#738 : JacksonInject is now preferred over the default argument(fixes #722).
Original file line number Diff line number Diff line change @@ -35,10 +35,18 @@ fun jsonMapper(initializer: JsonMapper.Builder.() -> Unit = {}): JsonMapper {
35
35
return builder.build()
36
36
}
37
37
38
- fun jacksonObjectMapper (): ObjectMapper = jsonMapper { addModule(kotlinModule()) }
39
- fun jacksonMapperBuilder (): JsonMapper .Builder = JsonMapper .builder().addModule(kotlinModule())
40
-
41
- fun ObjectMapper.registerKotlinModule (): ObjectMapper = this .registerModule(kotlinModule())
38
+ // region: JvmOverloads is set for bytecode compatibility for versions below 2.17.
39
+ @JvmOverloads
40
+ fun jacksonObjectMapper (initializer : KotlinModule .Builder .() -> Unit = {}): ObjectMapper =
41
+ jsonMapper { addModule(kotlinModule(initializer)) }
42
+ @JvmOverloads
43
+ fun jacksonMapperBuilder (initializer : KotlinModule .Builder .() -> Unit = {}): JsonMapper .Builder =
44
+ JsonMapper .builder().addModule(kotlinModule(initializer))
45
+
46
+ @JvmOverloads
47
+ fun ObjectMapper.registerKotlinModule (initializer : KotlinModule .Builder .() -> Unit = {}): ObjectMapper =
48
+ this .registerModule(kotlinModule(initializer))
49
+ // endregion
42
50
43
51
inline fun <reified T > jacksonTypeRef (): TypeReference <T > = object : TypeReference <T >() {}
44
52
You can’t perform that action at this time.
0 commit comments