我的 json 图片,请点击1 和2。 希望足够理解。
故事:我想读一次 Json 页面。没关系,我对此没有任何问题。我只能读取第一个单元格中的数据。不同类别的其他细胞。而且我通过使用http://www.jsonschema2pojo.org/ 重要!!每个不同的类型,都包含不同的命名对象列表。
但是如何通过改造库将每个单元格中的数据获取到不同的类?
##精选名单##
public class FeaturedList{
//this my main class
@SerializedName("featured")
private List<FeaturedItem> featured;
@SerializedName("type")
private String type;
@SerializedName("title")
private String title;
public void setFeatured(List<FeaturedItem> featured){
this.featured = featured;
}
public List<FeaturedItem> getFeatured(){
return featured;
}
public void setType(String type){
this.type = type;
}
public String getType(){
return type;
}
public void setTitle(String title){
this.title = title;
}
public String getTitle(){
return title;
}
@Override
public String toString(){
return
"FeaturedList{" +
"featured = '" + featured + '\'' +
",type = '" + type + '\'' +
",title = '" + title + '\'' +
"}";
}
主要活动
restInsterface = ApiClient.getClient().create(RestInsterface.class);
Call<List<FeaturedList>> listCall;
listCall=restInsterface.getFeaturedList();
listCall.enqueue(new Callback<List<FeaturedList>>() {
@Override
public void onResponse(Call<List<FeaturedList>> call, Response<List<FeaturedList>> response) {
for (FeaturedList item:response.body()){
Log.i(TAG, "onResponse: "+item.toString());
}
}
@Override
public void onFailure(Call<List<FeaturedList>> call, Throwable t) {
}
});
}
森林海
慕神8447489
相关分类