How to get list as response from jersey2 client

后端 未结 4 580
没有蜡笔的小新
没有蜡笔的小新 2020-12-30 23:23

I want to know how I can extract a List as response from the jersey-2.0 client.

I have already tried this,

Li         


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-30 23:42

    String listString= serviceResponse.readEntity(String.class);
    Gson gson=new Gson();
    Type type = new TypeToken>(){}.getType();
    List list = gson.fromJson(listString, type);
    

    Get response string and then convert to List by using gson library

提交回复
热议问题