反序列化
@JsonProperty(“SaleOrders”)可以识别xml和json
@JsonProperty(“SaleOrders”)
private List saleOrders;
@Data
@JacksonXmlRootElement(localName = "SaleOrder")
@JsonIgnoreProperties(ignoreUnknown = true)
public class SaleOrder {}
序列化
变成json可以识别@JsonProperty(“SaleOrders”)
变成xml需要用@JacksonXmlElementWrapper,否则会变成两层的SaleOrders<SaleOrders><SaleOrders><WarehouseCode>571DCF</WarehouseCode>@JacksonXmlElementWrapper使用:@JacksonXmlElementWrapper(localName = "AllocationOrders")@JacksonXmlProperty(localName ="AllocationOrder")@JsonProperty("AllocationOrders")private List<AllocationOrderResp> details;