对于本课程
public class Income {
Map<String, BigDecimal> monthly = new HashMap<>();
BigDecimal total = new BigDecimal("0.00");
}
我想生成这个XML:
<INCOME>
<JAN>1</JAN>
<FEB>2</FEB>
<TOTAL>3</TOTAL>
</INCOME>
所以我这样注释:
public class Income {
Map<String, BigDecimal> monthly = new HashMap<>();
BigDecimal total = new BigDecimal("0.00");
@JsonAnyGetter
public Map getMonthly() {
return monthly;
}
@JacksonXmlProperty(localName = "TOTAL")
public BigDecimal getTotal() {
return total;
}
}
但是它会生成此XML(每月之前总计):
<INCOME>
<TOTAL>3</TOTAL>
<JAN>1</JAN>
<FEB>2</FEB>
</INCOME>
我尝试用几个不同的JsonPropertyOrder
注释类,但是它们都提供了相同的xml:
@JsonPropertyOrder({ "monthly", "TOTAL" })
@JsonPropertyOrder({ "MONTHLY", "TOTAL" })
@JsonPropertyOrder({ "JAN", "FEB", "TOTAL" })