Skip to content

Commit

Permalink
Merge remote-tracking branch 'FasterXML/2.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Nov 16, 2024
2 parents 28a1dbb + a15c278 commit f36c52a
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package tools.jackson.module.kotlin.test.github

import com.fasterxml.jackson.annotation.JsonTypeInfo
import tools.jackson.module.kotlin.readValue
import tools.jackson.module.kotlin.jsonMapper
import kotlin.test.Test
import kotlin.test.assertEquals

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "_type")
private sealed class BaseClass

private data class ChildClass(val text: String) : BaseClass()

class GitHub844 {
@Test
fun test() {
val json = """
{
"_type": "ChildClass",
"text": "Test"
}
"""

val jacksonObjectMapper = jsonMapper()
val message = jacksonObjectMapper.readValue<BaseClass>(json)

assertEquals(ChildClass("Test"), message)
}
}

0 comments on commit f36c52a

Please sign in to comment.