Jackson List Help - Java
This works perfectly fine for List of Strings.
XML
<Messages>
<Message>msg1</Message>
<Message>msg2</Message>
<Message>msg3</Message>
</Messages>
Jackson Code
@JacksonXmlElementWrapper(localName = "Messages")
@JacksonXmlProperty(localName = "Message")
public List<String> messages;
Try JAXB Annotations like this:
@XmlElementWrapper(name = "Messages")
// XmlElement sets the name of the entities
@XmlElement(name = "Message")
public List<Message> messages;
See http://wiki.fasterxml.com/JacksonJAXBAnnotations for using JAXB annotations with Jackson.
There's a good JAXB tutorial here:
http://www.vogella.com/articles/JAXB/article.html
and here:
https://jaxb.java.net/tutorial/index.html
I found the easy way to do this without adding more dependencies. You just use the annotations:
@JacksonXmlElementWrapper(localName = "Messages")
@JacksonXmlProperty(localName = "Message")
This question is what pointed me in the right direction. Jackson XML globally set element name for container types. You can also read about this annotation on the github page here