Skip to content

Commit a15c278

Browse files
authored
Merge pull request #856 from FasterXML/2.18
2.18
2 parents de82368 + 779cf85 commit a15c278

File tree

1 file changed

+30
-0
lines changed
  • src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.fasterxml.jackson.module.kotlin.test.github
2+
3+
import com.fasterxml.jackson.annotation.JsonTypeInfo
4+
import com.fasterxml.jackson.databind.ObjectMapper
5+
import com.fasterxml.jackson.module.kotlin.readValue
6+
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
7+
import kotlin.test.Test
8+
import kotlin.test.assertEquals
9+
10+
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "_type")
11+
private sealed class BaseClass
12+
13+
private data class ChildClass(val text: String) : BaseClass()
14+
15+
class GitHub844 {
16+
@Test
17+
fun test() {
18+
val json = """
19+
{
20+
"_type": "ChildClass",
21+
"text": "Test"
22+
}
23+
"""
24+
25+
val jacksonObjectMapper = ObjectMapper().registerKotlinModule()
26+
val message = jacksonObjectMapper.readValue<BaseClass>(json)
27+
28+
assertEquals(ChildClass("Test"), message)
29+
}
30+
}

0 commit comments

Comments
 (0)