我有关于从响应转换模型的查询。
{
"data":{
"dataList":[
{
"itemCode":"item-49861",
"itemTypeKey":"drugs",
"itemCategoryKey":"general",
"itemSubCategoryKey":"fever and pain",
"itemName":"Combiflam",
"displayName":"Combiflam tablet 250mg"
},
{
"itemCode":"item-298611",
"itemTypeKey":"drugs",
"itemCategoryKey":"general",
"itemSubCategoryKey":"fever and pain",
"itemName":"Crocin",
"displayName":"Crocin tablet 250mg"
}
],
"pageSize":2,
"dataSize":2
}
}
答案 0 :(得分:0)
Android studio文件->设置..->插件->浏览存储库.. seach“ GsonFormat” 复制数据
答案 1 :(得分:0)
以下是您的响应的模型类。 使用http://www.jsonschema2pojo.org/将Json响应转换为模型。
public class Data {
@SerializedName("dataList")
@Expose
private List<DataList> dataList = null;
@SerializedName("pageSize")
@Expose
private Integer pageSize;
@SerializedName("dataSize")
@Expose
private Integer dataSize;
public List<DataList> getDataList() {
return dataList;
}
public void setDataList(List<DataList> dataList) {
this.dataList = dataList;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Integer getDataSize() {
return dataSize;
}
public void setDataSize(Integer dataSize) {
this.dataSize = dataSize;
}
}
public class DataList {
@SerializedName("itemCode")
@Expose
private String itemCode;
@SerializedName("itemTypeKey")
@Expose
private String itemTypeKey;
@SerializedName("itemCategoryKey")
@Expose
private String itemCategoryKey;
@SerializedName("itemSubCategoryKey")
@Expose
private String itemSubCategoryKey;
@SerializedName("itemName")
@Expose
private String itemName;
@SerializedName("displayName")
@Expose
private String displayName;
public String getItemCode() {
return itemCode;
}
public void setItemCode(String itemCode) {
this.itemCode = itemCode;
}
public String getItemTypeKey() {
return itemTypeKey;
}
public void setItemTypeKey(String itemTypeKey) {
this.itemTypeKey = itemTypeKey;
}
public String getItemCategoryKey() {
return itemCategoryKey;
}
public void setItemCategoryKey(String itemCategoryKey) {
this.itemCategoryKey = itemCategoryKey;
}
public String getItemSubCategoryKey() {
return itemSubCategoryKey;
}
public void setItemSubCategoryKey(String itemSubCategoryKey) {
this.itemSubCategoryKey = itemSubCategoryKey;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
}
public class Example {
@SerializedName("data")
@Expose
private Data data;
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
}