users@jersey.java.net

[Jersey] Re: JSON document -> JAXB class ?

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Tue, 10 Jan 2012 12:44:34 -0800

On Tue, Jan 10, 2012 at 11:27 AM, Arun Gupta <arun.p.gupta_at_oracle.com>wrote:

> The endpoint is returning the response as:
>
> [
> { },
> { },
> { }
> ]
>
> Notice, this is an array, not an array nested in an object. Any
> suggestions on how the client-side POJO could look like ?
>
> List<Pojo> or Pojo[] from a JAX-RS endpoint return JSON like:
>
> {"pojo"
> :
> [{"id":"10","text":"some text"},{"id":"20","text":"more text"}]
> }
>


Possibily, but not necessarily: this wrapping is only done by some
conventions. POJO mapping for example would not add extra "pojo" property,
but rather return array as is. Adding wrapping is an "XMLism", since it is
required with XML; but it is not required from JSON perspective; and as
such this is done by libraries that use XML APIs.

-+ Tatu +-