从Android改型读取JSON字符串时出现问题。
{
"error": false,
"message": "Data Found.",
"company": [
{
"SUPP_ID": "4",
"SUPP_CODE": "CO_000004",
"CO_ID": "1",
"CO_NAME": "Carrots",
"SUPP_NAME": "Chalakudy Suppliers",
"SUPP_SHORT_NAME": "CS",
"SUPP_MOBILE_1": "987654321",
"SUPP_MOBILE_2": "+1 ",
"SUPP_PHONE_1": "(456) 123-4561",
"SUPP_PHONE_2": "",
"SUPP_EMAIL": "chalakudi@gmail.com",
"SUPP_ADDR_1": "Chalakudi",
"SUPP_ADDR_2": "",
"SUPP_ADDR_3": "",
"SUPP_ADDR_4": "",
"SUPP_ADDR_5": "",
"SUPP_CITY_ID": "1864",
"SUPP_CITY_NAME": "Chalakudi",
"SUPP_STATE_ID": "19",
"SUPP_STATE_NAME": "Kerala",
"SUPP_COUNTRY_ID": "101",
"SUPP_COUNTYR_NAME": "India",
"SUPP_DF_PT_ID": "2",
"SUPP_PT_CODE": "Debit",
"SUPP_CR_UID": "1",
"SUPP_CR_DT": "2019-05-06 15:40:07",
"SUPP_UP_UID": "1",
"SUPP_UP_DT": "2019-05-06 15:41:41",
"SUPP_FRZ_YN": "0",
"SUPP_IS_DELETED": "0"
},
{
"SUPP_ID": "3",
"SUPP_CODE": "CO_000003",
"CO_ID": "1",
"CO_NAME": "Carrots",
"SUPP_NAME": "Aluva Suppliers",
"SUPP_SHORT_NAME": "Aluva",
"SUPP_MOBILE_1": "+91 9876543210",
"SUPP_MOBILE_2": "+919876543210",
"SUPP_PHONE_1": "(456) 123-123_",
"SUPP_PHONE_2": "",
"SUPP_EMAIL": "aluva@gmail.com",
"SUPP_ADDR_1": "aluva",
"SUPP_ADDR_2": "",
"SUPP_ADDR_3": "",
"SUPP_ADDR_4": "",
"SUPP_ADDR_5": "",
"SUPP_CITY_ID": "1849",
"SUPP_CITY_NAME": "Aluva",
"SUPP_STATE_ID": "19",
"SUPP_STATE_NAME": "Kerala",
"SUPP_COUNTRY_ID": "101",
"SUPP_COUNTYR_NAME": "India",
"SUPP_DF_PT_ID": "1",
"SUPP_PT_CODE": "Credit",
"SUPP_CR_UID": "1",
"SUPP_CR_DT": "2019-05-06 15:37:39",
"SUPP_UP_UID": "1",
"SUPP_UP_DT": "2019-05-06 15:38:00",
"SUPP_FRZ_YN": "0",
"SUPP_IS_DELETED": "0"
},
{
"SUPP_ID": "2",
"SUPP_CODE": "CO_000002",
"CO_ID": "1",
"CO_NAME": "Carrots",
"SUPP_NAME": "Angamaly Suppliers",
"SUPP_SHORT_NAME": "AS",
"SUPP_MOBILE_1": "+91 6543216540",
"SUPP_MOBILE_2": "+1 ",
"SUPP_PHONE_1": "(456) 123-4560",
"SUPP_PHONE_2": "",
"SUPP_EMAIL": "as@gmail.com",
"SUPP_ADDR_1": "6, Aluva Main Road\r\nAngamaly",
"SUPP_ADDR_2": "",
"SUPP_ADDR_3": "",
"SUPP_ADDR_4": "",
"SUPP_ADDR_5": "",
"SUPP_CITY_ID": "1851",
"SUPP_CITY_NAME": "Angamaly",
"SUPP_STATE_ID": "19",
"SUPP_STATE_NAME": "Kerala",
"SUPP_COUNTRY_ID": "101",
"SUPP_COUNTYR_NAME": "India",
"SUPP_DF_PT_ID": "1",
"SUPP_PT_CODE": "Credit",
"SUPP_CR_UID": "1",
"SUPP_CR_DT": "2019-05-02 10:55:46",
"SUPP_UP_UID": "1",
"SUPP_UP_DT": "2019-05-06 15:38:17",
"SUPP_FRZ_YN": "0",
"SUPP_IS_DELETED": "0"
},
{
"SUPP_ID": "1",
"SUPP_CODE": "CO_000001",
"CO_ID": "1",
"CO_NAME": "Carrots",
"SUPP_NAME": "Koratty Suppliers",
"SUPP_SHORT_NAME": "KS",
"SUPP_MOBILE_1": "+91 9876543210",
"SUPP_MOBILE_2": "+1 ",
"SUPP_PHONE_1": "(987) 654-3210",
"SUPP_PHONE_2": "",
"SUPP_EMAIL": "koratty@gmail.com",
"SUPP_ADDR_1": "4/2, Ernakulam High way,\r\nKoratty",
"SUPP_ADDR_2": "",
"SUPP_ADDR_3": "",
"SUPP_ADDR_4": "",
"SUPP_ADDR_5": "",
"SUPP_CITY_ID": "1940",
"SUPP_CITY_NAME": "Koratty",
"SUPP_STATE_ID": "19",
"SUPP_STATE_NAME": "Kerala",
"SUPP_COUNTRY_ID": "101",
"SUPP_COUNTYR_NAME": "India",
"SUPP_DF_PT_ID": "1",
"SUPP_PT_CODE": "Credit",
"SUPP_CR_UID": "1",
"SUPP_CR_DT": "2019-05-02 10:41:16",
"SUPP_UP_UID": "1",
"SUPP_UP_DT": "2019-05-02 10:43:35",
"SUPP_FRZ_YN": "0",
"SUPP_IS_DELETED": "0"
}
]
}
public class ApiResponse {
public boolean error;
public String message;
@SerializedName("company")
public List<Company> companyList;
}
class Company {
@SerializedName("SUPP_ID")
public int suppId;
@SerializedName("SUPP_CODE")
public String suppCode;
@SerializedName("CO_ID")
public String coID;
@SerializedName("CO_NAME")
public String coName;
@SerializedName("SUPP_NAME")
public String suppName;
@SerializedName("SUPP_SHORT_NAME")
public String suppShName;
@SerializedName("SUPP_MOBILE_1")
public String suppMobile1;
@SerializedName("SUPP_MOBILE_2")
public String suppMobile2;
@SerializedName("SUPP_PHONE_1")
public String suppPhone1;
@SerializedName("SUPP_PHONE_2")
public String getSuppPhone2;
@SerializedName("SUPP_EMAIL")
public String suppEmail;
@SerializedName("SUPP_ADDR_1")
public String suppAddr1;
@SerializedName("SUPP_ADDR_2")
public String getSuppAddr2;
@SerializedName("SUPP_ADDR_3")
public String suppAddr3;
@SerializedName("SUPP_ADDR_4")
public String suppAddr4;
@SerializedName("SUPP_ADDR_5")
public String suppAddr5;
@SerializedName("SUPP_CITY_ID")
public String suppCityId;
@SerializedName("SUPP_CITY_NAME")
public String suppCityName;
@SerializedName("SUPP_STATE_ID")
public String suppStateId;
@SerializedName("SUPP_STATE_NAME")
public String suppStateName;
@SerializedName("SUPP_COUNTRY_ID")
public String suppCountryId;
@SerializedName("SUPP_COUNTYR_NAME")
public String suppCountryName;
@SerializedName("SUPP_DF_PT_ID")
public int suppDfPtId;
@SerializedName("SUPP_PT_CODE")
public String suppPtCode;
@SerializedName("SUPP_CR_UID")
public int suppCrUid;
@SerializedName("SUPP_CR_DT")
public String suppCrDt;
//"2019-05-06 15:40:07"
@SerializedName("SUPP_UP_UID")
public int suppUpUid;
@SerializedName("SUPP_UP_DT")
public String suppUpDt;
@SerializedName("SUPP_FRZ_YN")
public int suppFrzYn;
@SerializedName("SUPP_IS_DELETED")
public int suppIsDeleted;
}
使用以下代码,您期望从json中获得其他东西,然后您实际上得到了。
public interface ApiInterface {
@FormUrlEncoded @POST("index.php")
Call<List<ApiResponse>> getSupplier(@Field("action") String action);
}
将其更改为:
public interface ApiInterface {
@FormUrlEncoded @POST("index.php")
Call<ApiResponse> getSupplier(@Field("action") String action);
}
你可以走了:)
使用返回类型调用
所以这就是json,改型期望从您的符号中得到:
[
{"error": false,
"message": "Data Found.",
"company": [...]
},
{"error": false,
"message": "Data Found.",
"company": [...]
}
...
]
我找到了一些解决方案,但我真的不知道如何开始。 这是我的密码。 接口 主要活动
我正在使用Retrofit和RxJava库并尝试解析此url: 我的代码如下。 APIInterface.java 主要活动。Java语言 我的模型课如下 大学生Java语言 我正在 D/错误:java。lang.IllegalStateException:应为BEGIN\u数组,但在日志的第1行第2列路径$处为BEGIN\u对象 我到处都在搜索这个错误,但找不到关于RxJava和改型的任何信息。
我正在使用Retro-Fit连接到API online。但是我在尝试解析返回的数据时遇到了这个错误。 返回的数据采用这种格式,数据模型也如下所示:
我试图只获取字符串请求,但它的给定错误如下 我的API输出如下: 响应代码:
我有一个API,为了获取数据,我必须发送一个JSON参数。这是必须在中发送才能获取数据的JSON。 它在postman中工作,但在Android中,我有以下错误: 我想这是我的模型中的一个问题,但我无法修复它。 我的型号: 还有两种型号用于排序和筛选。我使用改装 我使用构造函数设置SendParametersGetData(在本例中,仅设置了视图名和参数),并将其作为输入提供给getMembers
我从以下改装服务中获得了一个json结果: 我在改装后变得像bellow一样: 但是告诉我: 下面是我的模型: