FasterXML / FasterXML/jackson-dataformat-xml
XML Serialization + JsonAnyGetter as attributes
- Dominant language
- Java
- Stars
- 631
- Forks
- 246
- Avg merge
- 7d 9h
- Merged PRs (30d)
- 13
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:
```java
@JacksonXmlRootElement(localName = "metadata")
private static class ObjectWithAttributes {
@JsonAnyGetter
public Map getData() {
Map map = new HashMap<>();
map.put("a", "some value");
map.put("b", "and another one");
return map;
}
}
```
I was expecting to get the following XML :
```xml
```
but got:
```xml
some value
and another one
```
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.