users@jersey.java.net

[Jersey] Re: how to rename XmlRootElement in JSON

From: Maxrunner <joao.rossa_at_gmail.com>
Date: Fri, 27 May 2011 09:42:31 -0700 (PDT)

So how can i use the xmlrootelement annotation on List type without
extending it?can you help me with this?ive lost too much time with this
already....
regards,

On Fri, May 27, 2011 at 5:36 PM, Cowtowncoder [via Jersey] <
ml-node+6411705-1876304795-73314_at_n2.nabble.com> wrote:

> On Fri, May 27, 2011 at 6:47 AM, Jakub Podlesak
> <[hidden email] <http://user/SendEmail.jtp?type=node&node=6411705&i=0>>
> wrote:
> > Tatu needs to confirm, but i think, you should be able to write and
> register
> > your custom JsonSerializer to change the JSON name for the
> > List<OrganicaMobileEntity>.
>
> One thing to note is that while Jackson does support root element
> wrapping (SerializationConfig.Feature.WRAP_ROOT_VALUE), it is based on
> root value instance type.
> And if type happens to be List or Map, that List or Map type must have
> @XmlRootElement annotation.
> Alternatively it is possible to override
> JacksonAnnotationIntrospector.findRootName(annotatedClass) method to
> define custom handling.
>
> Aside from that, I personally prefer more explicit handling of
> wrapping by just introducing either single-entry Map, or
> single-property POJO, instead of relying on other methods for
> injecting extra layers. Sometimes more explicit approach is simpler
> and works better than magic features.
>
> -+ Tatu +-
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6411705.html
> To unsubscribe from how to rename XmlRootElement in JSON, click here<http://jersey.576304.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=6173292&code=am9hby5yb3NzYUBnbWFpbC5jb218NjE3MzI5MnwyMDYzODA1MDkw>.
>
>


--
View this message in context: http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6411725.html
Sent from the Jersey mailing list archive at Nabble.com.