我有一個JSON對象,看起來像這樣改造返回null對象
{
id:int,
tags: [
"string",
"string"
],
images: {
waveform_l:"url_to_image",
waveform_m:"url_to_image",
spectral_m:"url_to_image",
spectral_l:"url_to_image"
}
}
我試圖用改裝解析JSON並創建界面。我的問題是,我得到一個空的圖像網址。一切工作,我能夠檢索ID,標籤,但是當我試圖獲得圖像,他們都是空的。
我有一個完善的POJO,看起來像這樣:
public class Sound {
private Integer id;
private List<String> tags = new ArrayList<String>();
private Images images;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Images getImages() {
return images;
}
public void setImages(Images images) {
this.images = images;
}
... setters and getter for tags as well
}
,我有一個形象的POJO,看起來像這樣:
public class Images {
private String waveformL;
private String waveformM;
private String spectralM;
private String spectralL;
public String getWaveformL() {
return waveformL;
}
public void setWaveformL(String waveformL) {
this.waveformL = waveformL;
}
public String getWaveformM() {
return waveformM;
}
public void setWaveformM(String waveformM) {
this.waveformM = waveformM;
}
public String getSpectralM() {
return spectralM;
}
public void setSpectralM(String spectralM) {
this.spectralM = spectralM;
}
public String getSpectralL() {
return spectralL;
}
public void setSpectralL(String spectralL) {
this.spectralL = spectralL;
}
}
每當我打電話images.getWaveformM()它給我一個空指針。有任何想法嗎?
發佈GsonBuilder和RestAdapter創建代碼。 – njzk2 2014-10-07 19:26:23