users@jersey.java.net

[Jersey] HashMap manipulation to XML

From: Bruno Cardoso <bcardoso.home_at_gmail.com>
Date: Fri, 28 May 2010 16:03:11 +0100

Hi,

Lets say I have a class with:

@XmlRootElement
public class Client {
    private Long id;
    private String name;
    private Map<String, Object> customsFields;
}

This will result in a XML like:

<client>
   <id>1</id>
   <name>Bruno Cardoso</name>
   <customFields>
      <entry>
         <key>age</key>
         <value>28</value>
      </entry>
      <entry>
         <key>height</key>
         <value>178</value>
      </entry>
    </customFields>
</client>

Is it possible to change this behavior somewhere so I can get a XML like
this:

<client>
   <id>1</id>
   <name>Bruno Cardoso</name>
   <age>28</age>
   <height>178</height>
</client>

Thanks