Skip to content

Support use of xsi:type for polymorphic serialization (ToXmlGenerator.Feature.AUTO_DETECT_XSI_TYPE) #324

Description

@philipzhaoTS

Hey,

I have two subclasses like the following:

public abstract class Foo{}
public class Foo1 extends Foo {}
public class Foo2 extends Foo {}

And I want to generate XML as the following:

<Foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Foo1"></Foo>
<Foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Foo2"></Foo>

Notice there is xsi:type field in the XML.

In JAXB, I could do:
JAXBContext.newInstance(Foo.class, Foo1.class, Foo2.class);
Which will provide the xsi:type tag.

How would I do this in Jackson?
Many thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions