0
產生JSON這是我的代碼部分:奇怪行爲的研究,從對象
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "OAType", propOrder = {
"cDefCamelTDPDataList",
})
public class OAType {
@XmlElement(name = "c-def-camel-TDP-data-list", required = true)
protected cDefCamelTDPDataListType cDefCamelTDPDataList;
...
當我創建JSON有:
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
mapper.writerWithDefaultPrettyPrinter().writeValueAsString(tag); // Object tag
我得到:
{
"cDefCamelTDPDataList" : { },
"cdefCamelTDPDataList" : { },
...
我沒有」不明白錯在哪裏,Jackson爲什麼創建2次cDefCamelTDPDataList字段?