users@jersey.java.net

Re: [Jersey] How to serialize null property

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Thu, 23 Apr 2009 10:10:01 -0700

On Apr 23, 2009, at 10:01 AM, Tatu Saloranta wrote:

> On Thu, Apr 23, 2009 at 2:28 AM, <amsmota_at_gmail.com> wrote:
>> You can use your own NullObject, or use one of the many out there,
>> that
>> basically are obejcts with a
>>
>> String toString(){
>> return "null";
>> }
>>
>> But I don't know much about json, however...
>
> In near (?) future, regular nulls can be serialized as such too, with
> "native" JSON body writer (I sent a note a while back about prototype
> version based on Jackson's data mapper).
>
> Current problems with null stem (AFAIK) from the fact that xml itself
> really has no null concept (it's just text), and because associated
> schema info isn't (can't easily?) be passed through conversions from
> object -> (JAXB) xml -> (jettison) json.
>
For element content there's xsi:nil but that requires the schema to be
written accordingly (using nillable="true").

Marc