users@jersey.java.net

[Jersey] Re: Using Jackson for data binding with annotations

From: Julien Dreux <jdreux_at_justlexit.com>
Date: Mon, 14 May 2012 16:28:53 -0400

Tatu, you are truly a master.

My only complaint now is that all my null values get outputed, see below:


   1. {
   2. "name": "Subway",
   3. "deviceId": "12341234"
   4. "details": null,

*
*
Before I added that getSingletons line of code, they used to be omitted
from the JSON, which is the desired behaviour.

What can I do to make that work?

Thanks,


*JULIEN DREUX*
jdreux_at_justlexit.com
514 812-8084
www.justlexit.com


On Mon, May 14, 2012 at 4:17 PM, Tatu Saloranta <tsaloranta_at_gmail.com>wrote:

> On Mon, May 14, 2012 at 12:32 PM, Julien Dreux <jdreux_at_justlexit.com>
> wrote:
> > Here's how I am doing it. This works, I see the JSON generated, but the
> > output is still in a bad format:
> >
>
> Right. It seems to me that with this:
>
> > @Provider
> >
> > public abstract class AbstractBusinessServices extends Application
> > implements ContextResolver<JacksonJsonProvider>,
> >
> > ExceptionMapper<Exception>{
> >
> > private JacksonJsonProvider context;
> >
> > private Class[] types;
> >
> >
> > private Logger logger =
> > LoggerFactory.getLogger(AbstractBusinessServices.class.getName());
> >
> >
> > public AbstractBusinessServices() {
>
> you should just add something like:
>
> @Override
> public Set<Object> getSingletons() {
> Set<Object> s = new HashSet<Object>();
> s.add(new JacksonJsonProvider());
> return s;
> }
>
> to add the provider, and things would work...
>
> -+ Tatu +-
>