users@jersey.java.net

[Jersey] Upgrading from 1.2 to Jersey 1.4 breaks JSON?

From: Dominique Guinard <dev_at_guinard.org>
Date: Wed, 08 Dec 2010 16:38:38 -0500

I just realized that mail did not go through because of the attachment.
Sorry if you get it twice!

Dear all,

I upgraded from Jersey 1.2 to 1.4 and noticed that the outputted JSON
looks rather different.

Null values started to appear and some objects are represented
differently. Generally the JSON is a lot heavier than it used to be.

I read in a precedent thread ("Upgraded from Jersey 1.1 to 1.4, and JSON
now has "null" values throughout") that this happened to other devs but
the thread did not conclude anything.

Is this an actual bug? To me it seems like Jackson fires directly when
trying to create JSON objects, taking the precedence on JAXB.



I did not configure my app to use Jackson (although that was the idea to
support JSONp).

Is there a way to make sure Jackson does fire up? Or to configure it not
to output null values at least?

The precedent thread talked about using:

       MapperConfigurator configurator = new MapperConfigurator(null,
           new Annotations[] {Annotations.JAXB});
configurator.configure(SerializationConfig.Feature.WRITE_NULL_PROPERTIES, false);
       _mapper = configurator.getConfiguredMapper();


but I'm pretty clueless on where to put this code in my application. In
any resource?

Any help is warmly welcomed,

Dominique