【发布时间】:2026-01-04 08:45:01
【问题描述】:
我是Retrofit Library 的新手,我曾经使用 Volley
我正在尝试解析对象内部的数组,但我不知道该怎么做
这是我的 Json 回复
{
"response": {
"code": "1",
"success": true,
"customers": [
{
"id": 1,
"name": "reem",
"customer_type": "1",
"address": "45سسسس",
"mobile_no": "05684412211",
"phone_no": "414511555",
"created_at": "2018-07-30 08:26:48",
"updated_at": "2018-07-30 08:26:48"
}
]
}
}
我想从响应响应中获取客户数组 这是客户模型:
public class Customer {
@SerializedName("id")
private Integer id;
@SerializedName("customer_type")
private Integer customer_type;
@SerializedName("name")
private String name;
@SerializedName("address")
private String address;
@SerializedName("mobile_no")
private String mobile_no;
@SerializedName("phone_no")
private String phone_no;
public Customer(Integer id, Integer customer_type, String name, String address, String mobile_no, String phone_no) {
this.id = id;
this.customer_type = customer_type;
this.name = name;
this.address = address;
this.mobile_no = mobile_no;
this.phone_no = phone_no;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getCustomer_type() {
return customer_type;
}
public void setCustomer_type(Integer customer_type) {
this.customer_type = customer_type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getMobile_no() {
return mobile_no;
}
public void setMobile_no(String mobile_no) {
this.mobile_no = mobile_no;
}
public String getPhone_no() {
return phone_no;
}
public void setPhone_no(String phone_no) {
this.phone_no = phone_no;
}
}
这里是数据服务接口:
@GET("get_customers")
Call<List<Customer>> getAllCustomer();
你能帮我理解如何解析它吗?谢谢。
【问题讨论】:
标签: java android arrays json retrofit