I have tried this ,
List<String> list=client.target(url).
request(MediaType.APPLICATION_JSON).get(new GenericType<List<String>>(){});
but I am not getting the list instead I am getting null value
I have tried this ,
List<String> list=client.target(url).
request(MediaType.APPLICATION_JSON).get(new GenericType<List<String>>(){});
but I am not getting the list instead I am getting null value
Take your Response in the Response Object and then parse the Response Object using readEntity()
method.
Here is a quick code snippet:
Response serviceResponse = client.target(url).
request(MediaType.APPLICATION_JSON).get(Response.class);
List<String> list = serviceResponse.readEntity(new GenericType<List<String>>() {
});
String listString= serviceResponse.readEntity(String.class);
Gson gson=new Gson();
Type type = new TypeToken<List<String>>(){}.getType();
List<String> list = gson.fromJson(listString, type);
Get response string and then convert to List by using gson library
1) Take your Response in the then parse the Response Object using readEntity() method.
List<String> list = client.target(url).
request(MediaType.APPLICATION_JSON).get(Response.class).readEntity(new GenericType<List<String>>() {
});