FasterXML/jackson-modules-base

questions about serialized field names

Closed this issue · 2 comments

Describe the bug
// XML文件中的根标识

@XmlRootElement(name = "license")
@XmlType(propOrder = {
        "licInfo",
        "controlItems"
})
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class License {
    private LicInfo licInfo;

    private List<ControlItem> controlItems;


    public LicInfo getLicInfo() {
        return licInfo;
    }

    public void setLicInfo(LicInfo licInfo) {
        this.licInfo = licInfo;
    }

    @XmlElementWrapper(name="controlItems")
    @XmlElement(name = "controlItem")
    public List<ControlItem> getControlItems() {
        return controlItems;
    }

    public void setControlItems(List<ControlItem> controlItems) {
        this.controlItems = controlItems;
    }

    @Override
    public String toString() {
        return "License{" +
                "licInfo=" + licInfo +
                ", controlItems=" + controlItems +
                '}';
    }
}

Javax annotations affect the name of the serialized field,The json body returned by the URL call is overridden by the @xmlelement name. Expect controlItems instead of controlItem. An error is Caused if @JsonProperty is used: java.lang.IllegalStateException: Conflicting/ambiguous property name definitions (implicit name 'controlItems'): found multiple explicit names: [controlItems, controlItem], but also implicit accessor: [method com.xxx.license.vo.License#setControlItems(java.util.List)][visible=true,ignore=false,explicitName=false]

Version information
2.12.1

To Reproduce
Only annotations that contain @xmlelement will have its serialized content dominated by its value

Expected behavior
controlItems is expected to be returned

Looks like this is using JAXB annotations, so belongs to another repo; will transfer.

Now I just return with a new Po, but this makes me feel limited