I have a REST api GET call that takes an array of strings formatted as JSON. I’d like to use Jersey to convert that array of strings to something like a string array or List. I’ve reviewed http://jersey.java.net/nonav/documentation/latest/json.html, but it looks like Jersey wants me to create an object that specifies how it should be mapped, which I really don’t want to do because it’s just a simple array.
@GET
public Response get(@QueryParam("json_items") String requestedItems) throws IOException
{
//Would like to convert requestedItems to an array of strings or list
}
I know there are lots of libraries for this – but I’d prefer to use Jersey and not introduce any new libraries.
Just try to add to your Response the array, like
and see what happen.
If it’s just a very simple array it should be parsed without any problem.
EDIT:
If you want to receive it then just accept an array instead of a String. Try with a List or something like this.
Otherwise you can try to parse it using an ObjectMapper