-
-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support use of xsi:type
for polymorphic serialization (ToXmlGenerator.Feature.AUTO_DETECT_XSI_TYPE
)
#324
Comments
With Jackson you would need to use |
There's currently no way to do this out of the box.
The last problem is a dealbreaker, and it is possible to get around it by jumping through some hoops, but you might be better off just doing string replace on the final XML file. |
I wonder if one solution here would be addition of base implementation of handled to use with Or, possibly, XML-module-specific annotation to indicate that "type id" should be embedded "as attribute" -- problem being that although we could in theory just add a new But since this module already overrides quite a few pieces of Polymorphic Id handling, it just might be possible to tweak output to be done as attribute. Deserializer would handle it fine, I think, since attribute values are exposed similar to element values, but preceding them (which is actually good for use case). This would just be part of the problem of course, but it could be the first step. |
Is there any update on this? |
At this point it's a "PRs welcome" -- I would definitely like to add support but do not want enough to time to work on everything and this is not at the top of the pile. But as usual I try hard to make time to help others if and when they try to provide a PR. Ability to produce namespace might be somewhat doable but likely requires work on Fundamentally, tho, what one needs is a |
I have an idea of how to make this work, without having to make How about If so, I hope to have time to play with this to see how feasible it is. |
xsi:type
for polymorphic serialization (ToXmlGenerator.Feature.AUTO_DETECT_XSI_TYPE
)
Implemented via #633: generation-side support enabled with Will file counterpart for reader side next. |
Hey,
I have two subclasses like the following:
And I want to generate XML as the following:
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
The text was updated successfully, but these errors were encountered: