-
-
Notifications
You must be signed in to change notification settings - Fork 142
XML collection duplicated element names #242
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
Comments
I think this would belong under |
In Java this code works if I use the JavaBean pattern to create the domain model. It sounds like JacksonXmlElementWrapper doesn't really work very well with immutable Java objects [1]. In Scala I'd like to avoid JavaBean since case-classes use immutability. Is there a way to control the element names for Seq/immutable lists? Either with JacksonXmlElementWrapper or something else? Thanks! |
@peregin55 Perhaps this has more to do with problems with case classes, related to handling of However what would be useful would be equivalent json-only example, I think. |
+1 have this issue with scala List |
Come to think of it, there's a good chance this would be due to XML-specific extra handling that is required. But if anyone can double-check to ensure this can not be reproduced with json, that would be great. Building a combined test is problematic from module perspective; neither module should (ideally) depend on each either wrt releases. |
+1 have this issue with scala List |
I had the same issue. I fixed it with adding new constructor with a different signature than the built-in one, and marking it as @JsonCreator. I also had to change annotations so they don't get applied on the constructor parameters. This is how the code should look like (I didn't verify it with the case from this issue, so there may be typos):
See also this one: https://blog.adamfurmanek.pl/2024/05/20/serializing-collections-with-jackson-in-scala-and-renaming-the-nested-element/ |
I'm having trouble getting a case class with a collection field to serialize the way I want.
I have a data model that looks like this:
And I'm using Jackson to produce an XML:
The document that looks like this:
But
<authors>
is duplicated with its nested elements. I want the<authors>
tag to contain a list of<author>
elements.I can get this output by adding the following annotations to the Header case class:
This serializes the way I want, but when deserializing I get the following exception:
Is there something I can do to get this to deserialize properly?
Thanks for your help!
The text was updated successfully, but these errors were encountered: