我是使用改造的新手......我可以得到id
,title
但thumbnail
我不能在arraylist上得到对象tags
......?
请告诉我我该怎么办...
这是我的json:
{
code: 200,
result: {
id: "7064",
title: "my title",
thumbnail: "http://myimage.com/image.jpg",
tags: [
{
name: "php",
slug: "php"
},
{
name: "dependencies manager",
slug: "dependencies-manager"
},
{
name: "dependencies",
slug: "dependencies"
},
{
name: "packagist",
slug: "packagist"
}
]
}
}
这是我使用 gson 序列化的模型
public class Detail extends Observable implements Serializable {
@SerializedName("code")
public Integer code;
@SerializedName("result")
public Result result;
public class Result implements Serializable {
@SerializedName("id")
public String id;
@SerializedName("title")
public String title;
@SerializedName("date")
public String date;
@SerializedName("thumbnail")
public String thumbnail;
@SerializedName("tags")
public ArrayList<Tags> tags = new ArrayList<>();
}
public class Tags implements Serializable {
@SerializedName("name")
public String name;
@SerializedName("slug")
public String slug;
public String getName() {
return name;
}
}
}
和我的 API
@GET("api/posts/detail/{id}")
Call<Detail> getDetails (@Path("id") String id);