2016-11-11 111 views
-1

我已經創建了一個休息Web服務和一個客戶端。客戶正在調用一個函數來獲取所有播放列表。服務正在返回對象列表(播放列表)。如何將此響應保存在客戶端上?如何在java中處理json響應?

資源類:

@GET 
public List<Playlist> getAllPlaylists(){ 
    return playlistservice.getAllPlaylists(); 
} 

服務類:

public List<Playlist> getAllPlaylists(){ 
    return new ArrayList<Playlist>(playlists.values()); 
} 

客戶端代碼(在這裏即時得到錯誤)

List<Playlist> a = new ArrayList<Playlist>(); 

         a = playlistsTarget 
           .request() 
           .get(List<Playlist>.class); // error here 

如何保存這個響應播放列表?

+0

請出示理解的客戶端代碼有一點更多的背景 –

+0

可能的複製[JSON泛型集合反序列化(HTTP:/ /stackoverflow.com/questions/39273998/json-generic-collection-deserialization) – Jezor

回答