我正在尝试将XML字符串转换为Map,下面的代码可以很好地进行转换,但是我希望Map键以统一的方式(小写或大写)呈现。
public static void main(String[] args) throws Exception {
XmlMapper xmlMapper = new XmlMapper();
xmlMapper.setPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CASE);
String xml = "<Find Status=\"Success\"><Result><Provider><lastUpdated>1545391251168</lastUpdated></Provider></Result></Find>";
System.out.println(xmlMapper.readValue(xml.getBytes(), Map.class));
}
实际输出是:
{Status = Success,Result = {Provider = {lastUpdated = 1545391251168}}}
期望输出是:
{status = Success,result = {provider = {lastupdated = 1545391251168}}}
依赖项:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.8</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.9.8</version>
</dependency>