users@jersey.java.net

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

From: Pulkit Singhal <pulkitsinghal_at_gmail.com>
Date: Mon, 3 Sep 2012 16:54:26 -0500

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.

Here's an example:

@Produces(MediaType.APPLICATION_JSON)
public Product[] getProducts() {
...
return webResource.method("GET", new GenericType<List<Product>>(){});
}

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?