I want to know how I can extract a List<String> as response from the jersey-2.0 client.
I have already tried this,
List<String> list = client .target(url) .request(MediaType.APPLICATION_JSON) .get(new GenericType<List<String>>(){}); But, the above code is not working. It is not returning the expected List<String> but, a null value instead.
You can get your service response as Response class object and, then parse this object using readEntity(...) method.
Here is a quick code snippet:
List<String> list = client .target(url) .request(MediaType.APPLICATION_JSON) .get(Response.class) .readEntity(new GenericType<List<String>>() {}); /* Do something with the list object */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With