users@jersey.java.net

[Jersey] Re: _at_XmlJavaTypeAdapter doesn't seem to work with Jersey

From: Srinivas Naresh Bhimisetty <shri.naresh_at_gmail.com>
Date: Thu, 22 Nov 2012 15:23:20 +0530

Thanks Tatu. I'll try this.

On Thu, Nov 22, 2012 at 12:50 AM, Tatu Saloranta <tsaloranta_at_gmail.com>wrote:

> On Wed, Nov 21, 2012 at 4:18 AM, Srinivas Naresh Bhimisetty
> <shri.naresh_at_gmail.com> wrote:
> > Tatu,
> >
> > using the JacksonJaxbJsonProvider does help for this particular case,
> but
> > this causes issues where I have the beans annotated with JAXB having the
> > accessor type set as FIELD, meaning few of the properties in the bean
> could
> > be optional. While unmarshalling JSON complains about these optional
> > properties being not set as ignorable.
>
> There are many ways to ignore properties, as per:
>
> http://wiki.fasterxml.com/JacksonHowToIgnoreUnknown
>
> but I think most users who are not afraid of accidentally losing
> important properties due to mismatching names (my biggest peeve with
> JAXB -- it was happy to ignore all data, when names didn't match) use:
>
>
> objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,
> false);
>
> The only trick being how to specify ObjectMapper that Jersey uses --
> it is just a regular provideable thing, so you can use the usual
> JAX-RS provider. Or explicitly configure JacksonJaxbJsonProvider.
>
> -+ Tatu +-
>