Skip to content

Problem with Enums, @JsonTypeInfo (and indirectly, As.WRAPPER_ARRAY) #9

Open
@cowtowncoder

Description

@cowtowncoder

(from Jackson user forum by Rich M)

Hi all. I am using jackson 1.7.1 and xml-databind 0.5.3, and ran into a minor issue. I have an attribute of type Object, which is unavoidable because its value can be a primitive or an Enum. I have tagged the attribute with @JsonTypeInfo. Everything works fine in JSON, however, the xml is erroneous when working with an Enum:

public class MyClass {  
    @JsonTypeInfo(use=JsonTypeInfo.Id.MINIMAL_CLASS, include=JsonTypeInfo.As.PROPERTY, property="__type")
    public Object value;
}

The JSON fragment for an Enum is:

"value" : [ "PersonBloodTypeCode", "ABMNUS" ]

The XML fragment does not nest properly. It looks like:

<value>PersonBloodTypeCode</value>
 <value>ABMNUS</value>

Which, when deserialized, results in a String instance "ABMNUS", rather than an enum.

Metadata

Metadata

Assignees

No one assigned

    Labels

    has-failing-testIndicates that there exists a test case (under `failing/`) to reproduce the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions