Skip to content

Commit

Permalink
Merge pull request #856 from FasterXML/2.18
Browse files Browse the repository at this point in the history
2.18
  • Loading branch information
k163377 authored Nov 16, 2024
2 parents de82368 + 779cf85 commit a15c278
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.fasterxml.jackson.module.kotlin.test.github

import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
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 = ObjectMapper().registerKotlinModule()
val message = jacksonObjectMapper.readValue<BaseClass>(json)

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

0 comments on commit a15c278

Please sign in to comment.