users@jersey.java.net

Upgraded from Jersey 1.1 to 1.4, and JSON now has "null" values throughout

From: Tim McCune <tim_at_mccune.name>
Date: Tue, 28 Sep 2010 15:08:12 -0700

When using Jersey 1.1, if I had an object with properties that were null,
they simply didn't appear in the JSON output (same as XML).

{"message":"foo"}

I just upgraded to Jersey 1.4, and now my JSON output has a bunch of "null"
values in the output:

{"message":"foo","updated":null,"created":null}

I guess this has to do with the fact that Jersey switched to using Jackson
for its JSON rendering? I found a mention here:
http://docs.codehaus.org/display/JACKSON/FAQ
that including these "null" properties is actually the default behavior in
Jackson (??), and there is a way to turn it off, but I don't see any good
way to get at the underlying objectMapper object through the JAX-RS APIs.

Can anyone offer any suggestions?

Thanks.