Reputation: 420
I am trying to figure out how to change the root node name using jackson fasterxml.
For example:
public class Car {
@JsonProperty("engine-type")
String engineType = "v8";
}
public class Ford extends Car {
}
Ford car = new Ford();
ObjectMapper xmlMapper = new XmlMapper();
System.out.println(xmlMapper.writeValueAsString(this));
results in:
<Ford><engine-type>v8</engine-type></Ford>
This is what I want:
For example:
<car><engine-type>v8</engine-type></car>
Thanks
Upvotes: 5
Views: 7834
Reputation: 133
I think you could find your solution here: How to deserialize XML with annotations using FasterXML Why don't you use @JacksonXmlRootElement like:
@JacksonXmlRootElement(localName = "car")
public class Ford extends Car {
}
Upvotes: 12