I have following Jackson annotated classes (Kotlin)
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type"
)
@JsonSubTypes(
value = [
JsonSubTypes.Type(value = Child1::class, name = "child1"),
JsonSubTypes.Type(value = Child2::class, name = "child2")
]
)
sealed class Parent
class Child1: Parent()
class Child2: Parent()
I try to deserialize JSON that does not contain type property but I provide concrete class so it should not matter
// Kotlin extension method provides type in runtime
mapper.readValue<Child1>(json)
I get Missing type id when trying to resolve subtype of ... anyway. Is there a way how to tell Jackson to use the type provided in the deserialization and not to try find it from the type property?