Skip to content

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

@philipzhaoTS

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.17Issues planned at earliest for 2.17

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions