public static void main(String[] args) throws IOException {
XmlMapper xmlMapper = new XmlMapper();
LinkedHashMap result = xmlMapper.readValue("<root><a>1</a><b>2</b></root>", LinkedHashMap.class);
System.out.println(result);
}
它返回:
{a=1, b=2}
如何让它保持这样的根元素:
{
root = {
a = 1,
b = 2
}
}
答案 0 :(得分:0)
Please consider creating a real POJO for this use-case as maps are not supported for root elements.