'com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve subtype of

I am trying to serialize an object of class ConstantValue

@JsonDeserialize(using = PropertyDeserializer::class)
@JsonTypeName("ConstantValue")
@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.PROPERTY,
    property = "jsonType"
)
class ConstantValue<T>(val from: T? = null, val till: T? = null, val list: List<T>? = null): RegulationExpression()
{

Its parent Class is

@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.PROPERTY,
    property = "type"
)
@JsonSubTypes(
    JsonSubTypes.Type(value = BrickPropertyValueExpression::class, name = "BrickPropertyValueExpression"),
    JsonSubTypes.Type(value = EvaluationExpression::class, name = "EvaluationExpression"),
    JsonSubTypes.Type(value = SimplePredicate::class, name = "SimplePredicate"),
    JsonSubTypes.Type(value = ConstantValue::class, name = "ConstantValue"),
    JsonSubTypes.Type(value = SimpleGraphSearchExpression::class, name = "SimpleGraphSearchExpression"),
    JsonSubTypes.Type(value = GraphSearchExpression::class, name = "GraphSearchExpression"),
    JsonSubTypes.Type(value = CountGraphSearchExpression::class, name = "CountGraphSearchExpression"),
    JsonSubTypes.Type(value = AggregateGraphSearchExpression::class, name = "AggregateGraphSearchExpression"),
)
@JsonIgnoreProperties(ignoreUnknown = true)
open abstract class RegulationExpression () {

    @JsonSerialize(nullsUsing = ExpressionIdSerializer::class)
    val id: UUID?=null

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    abstract fun getFullString():String

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    abstract fun getTraceString() :String
}

I got following exception when try to serialize an object

Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve subtype of [simple type, class com.fmetric.regulation.api.data.expression.RegulationPredicate]: missing type id property 'type'
 at [Source: (String)"{"jsonType":"ConstantValue","from":null,"till":null,"list":["java.util.ArrayList",[4.9E-324]],"id":"b16ec9ee-4bac-4e1d-bdb4-898070ef6800","valueType":"DOUBLE","traceString":"null","fullString":"null"}"; line: 1, column: 200]
    

full log here https://gist.github.com/iva-nova-e-katerina/194519ed72a854d03737641aa9179a17

This is how I instantiate target class:

val expression1 = ConstantValue(null, null, mutableListOf(Double.MIN_VALUE))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source