[Jersey] nil instead of null

From: nbaliga <>
Date: Thu, 22 Sep 2011 12:45:33 -0700 (PDT)

I annotate my POJOs with JAXB annotations and I had a question about Jersey's
behavior when it comes to attributes marked with @XmlElement(nillable =

When I use the POJO Mapping Feature, I get, what I think is the correct JSON
notation, i.e.


However, for various reasons, I am forced to go with the JAXB Context
Resolver approach i.e. have a class such that:

class JAXBContextResolver
      implements ContextResolver<JAXBContext>

And in the constructor of said class, I set my JAXBContext instance =

 new JSONJAXBContext( JSONConfiguration.natural().rootUnwrapping( false
).humanReadableFormatting( true ).build(), .... );

By doing so, my understanding is that I am asking Jersey to use Jackson and
I get some more control over what it produces. Incidentally, the
rootUnwrapping feature is the reason for this approach over POJO Mapping

Using the above, causes null attributes to show up as:


How do I go about getting Jersey to go back to using null instead of nil? I
know the default Jackson behavior is to use null and not nil, both from my
experimentation with the POJO mapping feature, as well as simple POCs using
Jackson directly.

Any help will be greatly appreciated.

View this message in context:
Sent from the Jersey mailing list archive at