I guess using the Kotlin Jackon mapper is not enou...
# jackson-kotlin
r
I guess using the Kotlin Jackon mapper is not enough, and I have to provide the annotations. I’ve simplified it down to a simple test:
Copy code
import com.fasterxml.jackson.module.kotlin.readValue
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import kotlin.test.assertTrue


sealed class TestClass {
    data class TestMessageA(val name: String) : TestClass()
    data class TestMessageB(val age: Int) : TestClass()
}

class JacksonTest {

    @Nested
    inner class `Given JSON for a sealed class member` {
        @Test
        fun `it should map the Json to a representation`() {
            val json = """{"name": "test"}"""
            val mapper = com.fasterxml.jackson.module.kotlin.jacksonObjectMapper()

            println("Json: " + json)

            val testData = mapper.readValue<TestClass>(json)

            assertTrue {
                when (testData) {
                    is TestClass.TestMessageA -> true
                    is TestClass.TestMessageB -> false
                }
            }
        }
    }
}