Hmm...actually, I'm seeing a lot of behavior that I wouldn't expect, and
it's making me wonder if I'm doing something wrong. Jersey seems to be
skipping my JAXB annotations completely. My @XmlTransient properties are
showing up in my JSON output, and my @XmlJavaTypeAdapters are not being
used.
Has Jersey changed its default JSON marshalling to no longer go through
JAXB? Or am I doing something wrong? I haven't changed any code; I simply
upgraded Jersey from 1.1.4.1 to 1.4.
On Thu, Sep 30, 2010 at 2:12 PM, Tim McCune <tim_at_mccune.name> wrote:
> Thanks. I didn't realize that Jackson had this built in. Their
> documentation seems badly out-of-date. I haven't been able to get it to
> work with this code:
>
>
> mapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
>
> but using the deprecated version seems to work:
>
> mapper.configure(SerializationConfig.Feature.WRITE_NULL_PROPERTIES, false);
>
> At any rate, I realize that's now a question for the Jackson users mailing
> list. :) However, I'm still surprised that Jersey decided to change its
> default behavior to match what seems to be the default behavior of Jackson,
> to serialize null values. I would have expected Jersey to remain consistent
> with previous releases.
>
>
> On Tue, Sep 28, 2010 at 4:57 PM, Tatu Saloranta <tsaloranta_at_gmail.com>wrote:
>
>> On Tue, Sep 28, 2010 at 3:08 PM, Tim McCune <tim_at_mccune.name> wrote:
>> > 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?
>>
>> You should be able to register provider for ObjectMapper, and then
>> construct, configure and serve that?
>>
>> -+ Tatu +-
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>