FasterXML / FasterXML/jackson-modules-base
JAXB Module not handling polymorphic field name serialization when field annotated with XmlElements
- 主要言語
- Java
- スター
- 180
- フォーク
- 80
- 平均マージ
- 3時間 26分
- マージ済み PR(30日)
- 1
説明
I have the following JAXB annotations on a field in a given POJO:
```
@XmlElements({ @XmlElement(name = "source", type = Pojo.class, required = true), @XmlElement(name = "otherSource", type = PojoExtended.class, required = true) })
private Pojo sourceItem;
```
The underlying POJOs (Pojo and PojoExtended) are serialized into values correctly, but the field name remains "sourceItem" even though there is an array of XmlElement definitions that should examine the type and use the "name" attribute of the annotation to determine the field name. In other words, an object of type Pojo should use "source" as the field name, and an object of type PojoExtended should use "otherSource" as the field name.
The POJO that houses the sourceItem field is not under my control, so I cannot change it.
My ObjectMapper is configured as follows:
```
return new ObjectMapper()
.enable(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME)
.registerModule(new JaxbAnnotationModule())
```
It looks like the findWrapperName method in JaxbAnnotationIntrospector can only handle the XmlElementWrapper annotation correctly (used in another POJO in the code base), but doesn't handle the polymorphic XmlElements/XmlElement annotations correctly.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。