'Get Jackson XMLMapper to set root element name in code
How do I get Jackson's XMLMapper to set the name of the root xml element when serializing?
There's an annotation to do it, if you're serializing a pojo: @XmlRootElement(name="blah"). But I'm serializing a generic Java class, LinkedHashMap, so I can't use an annotation.
There's probably some switch somewhere to set it. Poking around in Jackson code, I see a class named SerializationConfig.withRootName(), but I've no clue how to use it.
Solution 1:[1]
You can use this annotation: @JsonRootName("MyCustomRootName")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | IPP Nerd |
