users@jersey.java.net

Serializing empty arrays as a result

From: Tom Schindl <tom.schindl_at_bestsolution.at>
Date: Tue, 10 Nov 2009 20:11:59 +0100

Hi,

I'm running into a problem with the Jersey-JSON serialization because I
need to satisfy an API which require me to serialize empty Collections.

The external party requires me to send JSON in the following format:

--------8<--------
{
  a : "Blabla",
  l : []
}
--------8<--------

but it looks like this is not possible to achieve with jersey because if
the l-attribute holds an empty list or null it is not part of the
serialized response:

--------8<--------
{
  a : "Blabla"
}
--------8<--------

Am I missing something obvious? What would you suggest to do instead?

Tom

-- 
B e s t S o l u t i o n . a t                        EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl                                        geschaeftsfuehrer/CEO
------------------------------------------------------------------------
eduard-bodem-gasse 5/1    A-6020 innsbruck      phone    ++43 512 935834