Reputation: 1
When try to trasform xml to json with jackson 2.12.7 (XMLMapper and ObjectMapper) have a problem with elements with attributes.
JsonNode node = xmlMapper.readTree(xml);
String json = objectMapper.writeValueAsString(node);
From xml:
<Address><Province Code="MI">MILAN</Province></Address>
obtain this json:
{"Province":{"Code":"MI","":"MILAN"}}
"":"MILAN"
How to set a default tag name when this is empty (es: "Value" or "City" etc etc)?
Upvotes: 0
Views: 105