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
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 {
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.