如何将此JSON格式转换为模型类,并使用retrofit将响应转换为列表


{
"data": [
{
"resource": "teams",
"id": 1,
"name": "Pakistan",
"code": "PAK",
"image_path": "https://cdn.sportmonks.com/images/cricket/teams/1/1.png",
"country_id": 190324,
"national_team": true,
"updated_at": "2018-11-29T11:47:20.000000Z"
}
]
}

你可以这样写

public class Response{
private List<Data> data;
// getter and setter
}
class Data{
private String resource;
private int id;
private String name;
private String code;
@SerializedName("image_path")
private String imagePath;
@SerializedName("country_id")
private long countryId;
@SerializedName("national_team")
private boolean nationalTeam;
@SerializedName("updated_at")
private String updatedAt;
// getters and setters
}

相关内容

  • 没有找到相关文章

最新更新