users@jersey.java.net

[Jersey] Re: Serializing a list of objects to JSON without artificial key names

From: Pulkit Singhal <pulkitsinghal_at_gmail.com>
Date: Mon, 3 Sep 2012 17:02:56 -0500

On Mon, Sep 3, 2012 at 4:54 PM, Pulkit Singhal <pulkitsinghal_at_gmail.com>wrote:

> My Jersey resource acts as the middle tier.
> It collects xml data from a 3rd party and serializes it back to my clients
> as JSON.
>

EDIT, the code example should actually look like this:
@Produces(MediaType.
APPLICATION_JSON)
public Product[] getProducts() {
...
return webResource
.method("GET", new GenericType<List<Product>>(){})
*.toArray(new Product[0])*;
}


But the JSON it returns isn't quite what I would expect to get:
> {
> "Product[]":[
> {...},
> {...}
> ]
> }
>
> There's an artificial key "Product[]" which I would rather name something
> like "products" ... is there some way to take control of this in Jersey?
>