users@jersey.java.net

JSON in Jersey

From: John Lister <john.lister_at_kickstone.com>
Date: Sun, 28 Feb 2010 15:24:40 +0000

Hi, sorry if this is the wrong place to ask...

I'm outputtng JSON via my Jersey resources, but I would like the JSON to
include null values.
For example I would like something like:
{
  aValue: "123",
  nullValue: null,
}

but at the minute the nulls are stripped and I get this:
{
  aValue: "123",
}

I tried using @XMLElement and specifying nillible and required, the
latter didn't make a difference and former gives me something like:

{
  aValue: "123",
  nullValue: {
        "@nill": "true",
  }
}

Is there a way to achieve what I want?
One thing is that I'm using the default notation as I haven't managed to
get the natural notation to work yet, would switching work?

Thanks


John