XmlElements includes unwanted intermediate elements.

4 views
Skip to first unread message

Leonel Gayard

unread,
Sep 2, 2025, 3:51:23 PMSep 2
to jackson-user
(Please forgive about doubling posting in the mailing list and github issues; I'm not sure about the etiquette and preferred channels, when reporting issues.)

As per raised issue #308 [1], when serializing to XML:

> One class has a List field annotated with @XmlElements. I expected that the object would be serialized into a parent element, and the contents of the list field would be direct children of that element. Instead, Jackson introduces an unwanted intermediary element, so that the contents of the list become grand children.

Note: I see different outputs when using Glassfish Jaxb and Jackson.

Can you advise? Is there some config I can apply to Jackson to change the output generation? Or is it a bug?

Leonel

Tatu Saloranta

unread,
Sep 4, 2025, 3:54:53 PMSep 4
to jackso...@googlegroups.com
It's a limitation wrt inclusion of Polymorphic Type Ids
(`@JsonTypeInfo` for regular Jackson annotations).

Handling is in XML module and there's an old issue:
https://github.com/FasterXML/jackson-dataformat-xml/issues/197

Unfortunately this is quite a difficult thing to support so no quick
fix is likely.

-+ Tatu +-


>
> --
> Leonel
>
> --
> You received this message because you are subscribed to the Google Groups "jackson-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/jackson-user/35c51622-1832-4a93-aff9-77e57f3f6609n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages