-
-
Notifications
You must be signed in to change notification settings - Fork 233
Open
Labels
3.xIssue planned for 3.x (and not 2.x)Issue planned for 3.x (and not 2.x)
Description
Hi there,
I'm having some issues with the serialization of dynamic data as attributes of an XML element.
Note: Tested on both version 2.9.6 and 2.9.7
Given the Object:
@JacksonXmlRootElement(localName = "metadata")
private static class ObjectWithAttributes {
@JsonAnyGetter
public Map<String, String> getData() {
Map<String, String> map = new HashMap<>();
map.put("a", "some value");
map.put("b", "and another one");
return map;
}
}I was expecting to get the following XML :
<metadata a="some value" b="and another one" />but got:
<metadata>
<a>some value</a>
<b>and another one</b>
</metadata>I tried to fiddle around with some of the annotations available be never got it to serialize the values as attributes.
I even tried to write a custom serializer which worked fine when annotating the class with the @JsonSerialize(using =...) but would results in any other attribute fields to not be serialized :(
I couldn't find any documentations regarding the uses of @JsonAnyGetter to get the values as attributes and not sub elements.
Is this use case not supported by Jackson ?
Thanks in advance,
Best regards.
Metadata
Metadata
Assignees
Labels
3.xIssue planned for 3.x (and not 2.x)Issue planned for 3.x (and not 2.x)