android - 响应是动态的:需要一个字符串,但在第 1 行第 149 列是 BEGIN_OBJECT
问题描述
这是我的 GSON 响应,我的响应是动态的。
注意:我无法更改响应
{ "soapBody": {
"GenerateProposalResponse": {
"GenerateProposalResult": {
"POL_SYS_ID": "102123205",
"PROPOSAL_NO": "10083\/31\/20\/P\/0004354",
"VehicleIDV": {
},
"ERROR_DESC": "Proposal created successfully......!",
"ERROR_CODE": "0",
"CoverDtlList": {
"CoverDtl": [
{
"CoverDesc": "BASIC TP COVER",
"Premium": "752",
"Type": {
}
},
{
"CoverDesc": "GR36A-PA FOR OWNER DRIVER",
"Premium": "315",
"Type": "ADD"
},
{
"CoverDesc": "TP TOTAL",
"Premium": "1067",
"Type": {
}
},
{
"CoverDesc": "TOTAL PREMIUM",
"Premium": "1067",
"Type": {
}
},
{
"CoverDesc": "IGST",
"Premium": "192",
"Type": "ADD"
},
{
"CoverDesc": "TOTAL AMOUNT",
"Premium": "1259",
"Type": {
}
}
]
}
}
} } }
很多时候,我得到了“VehicleIDV”:“1230”,很多时候我得到了“VehicleIDV”:{}
W/System.err:com.google.gson.JsonSyntaxException:java.lang.IllegalStateException:需要一个字符串,但在第 1 行第 149 列路径 $.soapBody.GenerateProposalResponse.GenerateProposalResult.VehicleIDV 是 BEGIN_OBJECT
这是我的功能
public void getShri(final Context mContext, String id) {
ApiClient restClient = new ApiClient(mContext);
restClient.setCommunication();
ApiInterface apiService = restClient.getApiService();
try {
Call call = apiService.getShri(id);
call.enqueue(new Callback<Shri>() {
@Override
public void onResponse(Call<Shri> call, Response<Shri> response) {
if (response.isSuccessful()) {
Shri commonResponse = response.body();
((onRequestCompleteCallBackListener) mContext).
onResponse(commonResponse);
}
}
@Override
public void onFailure(Call<Shri> call, Throwable t) {
//onResponse(t);
t.printStackTrace();
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
这是api接口代码
@FormUrlEncoded
@POST("shri.php")
Call<Shri> getShri(@Field("id") String id);
解决方案
推荐阅读
- ios - Xcode - 从嵌套框架访问 swift 类
- azure - AZ cli 向以连字符开头的密钥库添加机密
- php - 带有面包屑的 Laravel 8 添加动态页面标题
- lightgbm - 为什么这个简单的 LightGBM 二元分类器表现不佳?
- javascript - Scrolling to last appended item breaks after X appended items
- awk - 在一个文件的行中搜索另一个文件中的部分匹配项
- powershell - 使用 Test-Connection 时如何在 Powershell 中获取 ping 时间?
- python - ODOO XMLRPC 调用自定义方法在同一模型上创建记录
- azure - Azure Kubernetes - 如何确定可用于内部负载均衡器的 DNS 名称?
- git - 如何分叉你在 GitHub 上的仓库?