vinoth kumar v vinoth kumar v - 4 years ago 217
Java Question

Modify the Jackson Annotation from xml

I am using Jackson library in my project.

I am having a list data type like below

List<String> Names;


The output is produced is:

<Names>
<Names>bob</Names>
<Names>ram</Names>
</Names>


But I Expect the output to be like this :

<Names>
<Name>bob</Name>
<Name>ram</Name>
</Names>


I have used
@JacksonXmlElementWrapper
and
@JacksonXmlElement
, is there any generic way of doing this because i have huge list in my program.

Thanks in advance.

Answer Source

By using Following this two you can make the list like

 1. @JacksonXmlElementWrapper
 2. @JacksonXmlElement

Expected Output :

<Names>
<Name>bob</Name>
<Name>ram</Name>
</Names>

There is no other external thing given by Jackson for doing this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download