FasterXML / FasterXML/jackson-dataformat-xml
XML Serialization + JsonAnyGetter as attributes
- 主要語言
- Java
- 星號
- 631
- 分支
- 246
- 平均合併
- 7 天 9 小時
- 30 天內合併 PR
- 13
描述
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.
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。