Deserialize JSON into class that inherits using Jackson
I am having trouble deserializing a JSON into a class that inherits.
class Dog(...) : Animal {
override val type: AnimalType: AnimalType.DOG
}
class Cat(...) : Animal {
override val type: AnimalType:
AnimalType.CAT
}
interface Animal {
val index: Int
val type: AnimalType
}
enum class AnimalType(@JsonValue val type: String) {
CAT("cat")
DOG("dog"),
}
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes(...