Freddy
Freddy

Reputation: 876

Jersey split payload

I am wondering, if it is possible to split the payload in a request which is consumed by Jersey. I want to achieve this:

@PUT
@Path("/endpoint")
@Consumes(MediaType.APPLICATION_JSON)
public Response method(long[] vals1, long[] vals2) {
    // Do something...
}

The data I would send is structured as follows:

[ [1,2,3], [4,5,6] ]

Is this possible or do I have to send a Map-like object and update the signature of the method accordingly to a Set<String, List<Long>>?

{ "vals1": [1,2,3], "vals2": [3,4,5] }

Upvotes: 1

Views: 95

Answers (1)

Carlos
Carlos

Reputation: 71

You can create an object with both arrays inside and configure jersey to parse json using jackson. Then you should send the request with a json body:

{
"vals1": [1,2,3],
"vals2": [4,5,6]
}

Upvotes: 1

Related Questions