我想解析preview -> images ->source -> url
:
public class LChildData {
@SerializedName("title")
@Expose
public String title;
@SerializedName("preview")
@Expose
public LPreview preview;
}
public class LPreview {
@SerializedName("images")
@Expose
public List<LImages> images =null;
}
public class LImages {
@SerializedName("source")
@Expose
public LSource source;
}
public class LSource {
@SerializedName("url")
@Expose
public String url;
}
ViewHolder代码:
if (isValidImageUrl(holder.mItem.data.preview.images.get(0).source.url)) {
Picasso.with(mContext)
.load(holder.mItem.data.preview.images.get(0).source.url)
.into(holder.mPostThumbnail);
}
错误:
D / ViewAdapter:onBindViewHolder:image_url :https://i.redditmedia.com/RoARvRoBJHQihiWK_aHdhEZG2kabxNvmvY5kZKFkskk.jpg?s=037d08a057a7a6d253ab0937b6247353
java.lang.NullPointerException:尝试调用虚方法 &#39; java.util.List com.example.dex.redditclient.listings.model.LPreview.getImages()&#39;在com.example.dex.redditclient.listings.ViewAdapter.onBindViewHolder(ViewAdapter.java:60)的null对象引用上