users@jersey.java.net

Re: [Jersey] How do I marshal nested lists as JSON? I get an array of nulls or an array of one-element dictionaries containing an array.

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Mon, 20 Jul 2009 12:00:54 -0700

On Mon, Jul 20, 2009 at 8:59 AM, Stevens, Ian<IStevens_at_globeandmail.com> wrote:
> Hi Jakub. Thanks for your response.
>
...
>> I am sorry, but IMHO using the JAXB->JSON way, you will not
>> be able to get what you want.
>> You might want to use the low-level JSON approach [1] for
>> generating the JSON, or Tatu's Java->JSON provider [2].
>>
>> [1]https://jersey.dev.java.net/documentation/1.1.1-ea/user-gui
> de.html#d4e645
>> [2]http://www.cowtowncoder.com/blog/archives/2009/03/entry_229.html
>
> This is what I had expected. That really is unfortunate. The code I'm
> working on relies heavily on JAX-WS and JAX-RS. It's not my code, and
> there doesn't seem to be an easy way to override the JSON output for a
...

You might want to try approach #2, if you do control both client and
server sides; this so that you can add the provider. If so, it'll
replace other conventions for json. Doesn't affect xml part in any
way.
Pure Jackson JAX-RS providers works pretty well, and the main
challenge is just if other side is assuming use of mapping
conventions.

-+ Tatu +-