File tree 1 file changed +32
-0
lines changed
src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.fasterxml.jackson.module.kotlin.test.github
2
+
3
+ import com.fasterxml.jackson.annotation.JsonAnyGetter
4
+ import com.fasterxml.jackson.annotation.JsonAnySetter
5
+ import com.fasterxml.jackson.databind.ObjectMapper
6
+ import com.fasterxml.jackson.module.kotlin.KotlinModule
7
+ import com.fasterxml.jackson.module.kotlin.readValue
8
+ import kotlin.test.Test
9
+ import kotlin.test.assertEquals
10
+
11
+ class GitHub832 {
12
+ data class AnySetter @JvmOverloads constructor(
13
+ val test : String? = null ,
14
+ @JsonAnySetter
15
+ @get:JsonAnyGetter
16
+ val anything : Map <String , Any ?> = mutableMapOf(),
17
+ )
18
+
19
+ @Test
20
+ fun testDeserialization () {
21
+ val json = """
22
+ {
23
+ "widget": {
24
+ "debug": "on"
25
+ }
26
+ } """ .trimMargin()
27
+ val jacksonMapper = ObjectMapper ()
28
+ jacksonMapper.registerModules(KotlinModule .Builder ().build())
29
+ val anySetter = jacksonMapper.readValue<AnySetter >(json)
30
+ assertEquals(" widget" , anySetter.anything.entries.first().key)
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments