users@jersey.java.net

Re: [Jersey] Upgraded from Jersey 1.1 to 1.4, and JSON now has "null" values throughout

From: Tim McCune <tim_at_mccune.name>
Date: Thu, 7 Oct 2010 10:14:00 -0700

On Thu, Oct 7, 2010 at 1:07 AM, Jakub Podlesak <jakub.podlesak_at_oracle.com>wrote:

> On 10/07/2010 09:38 AM, Jakub Podlesak wrote:
>
>> On 10/06/2010 07:38 PM, Tatu Saloranta wrote:
>>
>>> On Wed, Oct 6, 2010 at 9:56 AM, Tim McCune<tim_at_mccune.name> wrote:
>>>
>>>> Hmm, I haven't made any changes to my application to enable Jackson.
>>>> Jersey
>>>> just started using Jackson when I upgraded from 1.1.5.1 to 1.4. So
>>>> maybe
>>>> there is some unintended side-effect of the way that I've always used
>>>> Jersey
>>>> that is enabling Jackson? At any rate, with Jackson doing the
>>>> marshalling,
>>>> I'd still expect it to not output the "null"s, which it seems to be
>>>> doing
>>>> when it's turned on in Jersey, regardless of whether or not it's
>>>> actually
>>>> supposed to be turned on. :)
>>>>
>>> It really depends on who is enabling support -- Jackson has no
>>> knowledge of Jersey, so it uses its defaults unless explicitly told
>>> otherwise.
>>> This behavior is not mandated by JAX-RS, either; so both approaches
>>> are equally valid from general viewpoint. I agree in that for
>>> backwards compatibility changes in behavior do not make sense.
>>>
>>
>> As i wrote in the other post, Jersey has not changed the default.
>> It is either a bug in Jersey or a misconfiguration on the application
>> side.
>>
>> In the previous post, i have also attached a test case application showing
>> that in the default case, the null values are not written out.
>>
>> My guess is Tim wants to utilize Jackson for non-JAXB classes
>> and JAXB otherwise, and this scenario is indeed not supported
>> at the moment in Jersey. But it is definitely a change in the default
>> behavior.
>>
>
> I meant *no change*,
>
> ~Jakub
>
>
>
>> Tim, could you please confirm?
>>
>
No, I don't care about using Jackson, and I have made no configuration
changes to enable it. That said, we do go through some effort to bend
Jersey to our will, providing our own JAXBContext resolver that allows us to
do XSS-prevention filtering during the XML & JSON parsing, but it's not
doing anything with Jackson, and not taking any specific steps to enable
Jackson. The code predates Jackson even being added to Jersey.