我正在使用gson将json数据解析为模型类,但是它引发了如下所述的错误。 我提到了一些SO问题,但无法解决问题。我正在使用此link作为参考。
Customer.class
public class Customer {
private String Bank_Name;
private String Bank_Bank;
private String Bank_Account_Clabe;
private String Bank_Accunt_Number;
public String getBank_Name() {
return Bank_Name;
}
public void setBank_Name(String bank_Name) {
Bank_Name = bank_Name;
}
public String getBank_Bank() {
return Bank_Bank;
}
public void setBank_Bank(String bank_Bank) {
Bank_Bank = bank_Bank;
}
public String getBank_Account_Clabe() {
return Bank_Account_Clabe;
}
public void setBank_Account_Clabe(String bank_Account_Clabe) {
Bank_Account_Clabe = bank_Account_Clabe;
}
public String getBank_Accunt_Number() {
return Bank_Accunt_Number;
}
public void setBank_Accunt_Number(String bank_Accunt_Number) {
Bank_Accunt_Number = bank_Accunt_Number;
}
}
Json响应
{
"Bank_Name": "",
"Bank_Bank": "",
"Bank_Account_Clabe": "",
"Bank_Accunt_Number": ""
}
错误日志
System.err: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unexpected value at line 1 column 13 path $.Bank_Name
代码
try {
GsonBuilder gb = new GsonBuilder();
Gson gson = gb.create();
Customer customer = gson.fromJson(s, Customer.class);
setData(customer);
} catch (Exception e) {
e.printStackTrace();
}