users@jersey.java.net

[Jersey] Re: how to rename XmlRootElement in JSON

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Tue, 15 Mar 2011 10:25:55 -0700

On Tue, Mar 15, 2011 at 8:54 AM, Pengfei Di <pengfei.di_at_match2blue.com> wrote:
> Hello,
>
> I tried to rename the root element of a jaxb class, that is easy for XML
> representation. However, it seems impossible for JSON representation.
> 1. put a JAXBContextResolver, as written in the Example5.5 of jersey guide.
> 2. add jackson 1.7.0 into the pom.xml.  (jackson-core-lgpl 1.7.0 and
> jackson-mapper-lgpl 1.7.0)
> Did I miss something?
>
> The JAXB class looks like:
> @XmlRootElement( name = "account" )
> public class MyAccount
> {
> int x;
> }

When using Jackson, there will not be a root element (JSON structure
differs from XML), so you might not be using POJO mapping with Jersey?
Other json producing methods do add wrapper property.

-+ Tatu +-