【发布时间】:2021-12-23 19:25:23
【问题描述】:
我有序列化为 xml 的 HashMap
HashMap<String, Object> h1 = new HashMap<>();
h1.put("test", null);
System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(h1));
Jackson 会生成类似的东西
<HashMap>
<test/>
</HashMap>
所以我需要以某种方式为这个空标签添加属性
<HashMap>
<test attribute = "something"/>
</HashMap>
有可能吗?
【问题讨论】:
标签: java xml jackson xml-serialization