Skip to content

Jackson is not able to deserialize when JsonIdentityInfo and JsonTypeInfo is used together. #290

Open
@muhemmedali

Description

@muhemmedali

I have Json to deserialize(copying the problematic chunk below)
"values" : [ { "IEnumerationValueClass" : "EnumerationValueName", "@id" : 243, "value" : 0, "id" : 3038, "comment" : "Indicates the calculation in net values.", "name" : "MonetaryNet", "type" : { "IDataTypeClass" : "EnumerationType", "values" : [ 243, { "IEnumerationValueClass" : "EnumerationValueName", "@id" : 244, "value" : 1, "id" : 3039, "comment" : "Indicates the calculation in gross values.", "name" : "MonetaryGross", "type" : { "IDataTypeClass" : "EnumerationType", "values" : [ 243, 244, { "IEnumerationValueClass" : "EnumerationValueName", "@id" : 245, "value" : 2, "id" : 3040, "comment" : "Indicates the calculation is using times as unit.", "name" : "Time", "type" : { "IDataTypeClass" : "EnumerationType", "values" : [ 243, 244, 245, { "IEnumerationValueClass" : "EnumerationValueName", "@id" : 246, "value" : 3, "id" : 3041, "comment" : "Indicates the calculation is using volume as unit.", "name" : "Volume", "type" : { "IDataTypeClass" : "EnumerationType", "values" : [ 243, 244, 245, 246, { "IEnumerationValueClass" : "EnumerationValueName", "@id" : 247, "value" : 4, "id" : 3042, "comment" : "Indicates the calculation is using bonus specific unit.", "name" : "Bonus", "type" : { "IDataTypeClass" : "EnumerationType", "values" : [ 243, 244, 245, 246, 247 ], "name" : "GLOBAL.UnitType", "comment" : "", "type" : 10440, "baseType" : [ "DataType", "Integer" ], "kind" : "mixed", "global" : true, "code" : 10440 } } ], "name" : "GLOBAL.UnitType", "comment" : "", "type" : 10440, "baseType" : [ "DataType", "Integer" ], "kind" : "mixed", "global" : true, "code" : 10440 } }, 247 ], "name" : "GLOBAL.UnitType", "comment" : "", "type" : 10440, "baseType" : [ "DataType", "Integer" ], "kind" : "mixed", "global" : true, "code" : 10440 } }, 246, 247 ], "name" : "GLOBAL.UnitType", "comment" : "", "type" : 10440, "baseType" : [ "DataType", "Integer" ], "kind" : "mixed", "global" : true, "code" : 10440 } }, 245, 246, 247 ]

When I try to deserialize following exception is thrown
com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Missing type id when trying to resolve subtype of [simple type, class IEnumerationValue]: missing type id property 'IEnumerationValueClass' (for POJO property 'values') at [Source: (StringReader); line: 91774, column: 28] (through reference chain: MainModel["searchActions"]->java.lang.Object[][3]->Table["columns"]->java.util.ArrayList[1]->TableColumn["types"]->java.util.ArrayList[0]->ColumnDataType["type"]->EnumerationType["values"]->java.util.ArrayList[0]->EnumerationValue["type"]->EnumerationType["values"]->java.util.ArrayList[0])

From what I see
After serializing the the json have the type info
"IEnumerationValueClass" : "EnumerationValueName", "@id" : 243,
but when the same id is refer in the json later on
"values" : [ 243, {
Jackson is not able to recognize the type.

Interface
@JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "IEnumerationValueClass") @JsonSubTypes({ @JsonSubTypes.Type(value = EnumerationValue.class , name = "EnumerationValueName"), }) public interface IEnumerationValue { .... }
Child class
@JsonIdentityInfo(generator= ObjectIdGenerators.IntSequenceGenerator.class, property="@id") public class EnumerationValue implements IEnumerationValue, Serializable, Cloneable { ...... }

Really appreciate the help.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    need-test-caseTo work on issue, a reproduction (ideally unit test) needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions