users@jersey.java.net

[Jersey] Re: how to rename XmlRootElement in JSON

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Tue, 07 Jun 2011 11:16:12 +0200

Hi Maxrunner,

Correct, you should be able to use different object mappers for different
types using Jersey 1.8-SNAPSHOT. See
src/main/java/com/sun/jersey/samples/jacksonjsonprovider/MyObjectMapperProvider.java
from [1] for an example.

~Jakub

[1]http://download.java.net/maven/2/com/sun/jersey/samples/jacksonjsonprovider/1.8-SNAPSHOT/jacksonjsonprovider-1.8-SNAPSHOT-project.zip

On 06/06/2011 12:33 AM, Maxrunner wrote:
> Hi! been on vacations so sorry for not answering sooner. But im
> currently using fixed 1.8 version that allows to use one or other
> mapper according to type. Can you verify this?
>
> regards,
>
> On Wed, Jun 1, 2011 at 8:04 AM, Jakub Podlesak-2 [via Jersey] <[hidden
> email] </user/SendEmail.jtp?type=node&node=6443338&i=0>> wrote:
>
> Hi,
>
> i just saw the super() and MyObjectMapperProvider() (this won't
> compile
> anyway, right;-)
> calls and wanted to make sure you understand, you can not have
> more than
> one ContextResolver<ObjectMapper> classes defined in your
> application,
> as more than one such resolvers would introduce an ambiguity.
>
> ~Jakub
>
> On 05/31/2011 11:47 AM, Maxrunner wrote:
>
> > Thanks jakub, its working fine now :). Still i didnt understand
> the second
> > correction you made to my contextresolver:
> >
> > "@Provider
> > public class JacksonObjectMapperProvider implements
> > ContextResolver<ObjectMapper>{
> >
> > private ObjectMapper defaultObjectMapper;
> > private ObjectMapper listsObjectMapper;
> >
> >
> > public JacksonObjectMapperProvider() {
> > super();
> > MyObjectMapperProvider();
> > }
> >
> > I do not know what the above means. Please note, that you should
> register
> > just one ContextResolver<ObjectMapper> instance, as Jackson
> will use only
> > the first one
> > if more that one such provider is found. To create different
> object mappers,
> > you should
> > use the getContext method bellow."
> >
> > Didnt understand this correction, can you elaborate?
> >
> > --
> > View this message in context:
> http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6422046.html
>
>
> > Sent from the Jersey mailing list archive at Nabble.com.
> >
>
>
>
> ------------------------------------------------------------------------
> 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-tp6173292p6425845.html
>
> To unsubscribe from how to rename XmlRootElement in JSON, click here.
>
>
>
> ------------------------------------------------------------------------
> View this message in context: Re: how to rename XmlRootElement in JSON
> <http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6443338.html>
> Sent from the Jersey mailing list archive
> <http://jersey.576304.n2.nabble.com/> at Nabble.com.