FasterXML / FasterXML/jackson-modules-base
JAXB Module not handling polymorphic field name serialization when field annotated with XmlElements
- Ngôn ngữ chính
- Java
- Star
- 180
- Fork
- 80
- Merge trung bình
- 3 giờ 26 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.