u013962582
luoye@yf
2016-06-27 07:55

com.google.gson.JsonSyntaxException

我使用的是谷歌提供的gson解析json数据。json数据如下"
{"flag":"0","data":{"id":"176","loginName":"18224006722","name":"18224006722","phone":"18224006722","mobile":"18224006722","loginToken":"c4b23c48bcc7a9bf4f4301cfeca4c3d2","isStoreAdm":"1","storeLogo":""},"tcount":0}
";网络方面我使用的是
OkHttpUtils。
使用自定义的
StringCallback()

public abstract class LoginCall extends Callback{ @Override public Login parseNetworkResponse(Response response) throws Exception {
String result = response.body().string();
Gson gson=new Gson(); return gson.fromJson(result,Login.class);
}
}

java实体类我使用的是GsonFormat自动生成的而且还序列化了的,结果就是要报这个异常,求解答。

哦哦,我不使用gson解析可以获取到json字符串,

java实体类:

public class Login implements Serializable{ private String flag; private DataBean data; private int tcount; public String getFlag() { return flag;
} public void setFlag(String flag) { this.flag = flag;
} public DataBean getData() { return data;
} public void setData(DataBean data) { this.data = data;
} public int getTcount() { return tcount;
} public void setTcount(int tcount) { this.tcount = tcount;
} public static class DataBean implements Serializable{ private String id; private String loginName; private String name; private String phone; private String mobile; private String loginToken; private String isStoreAdm; private String storeLogo; public String getId() { return id;
} public void setId(String id) { this.id = id;
} public String getLoginName() { return loginName;
} public void setLoginName(String loginName) { this.loginName = loginName;
} public String getName() { return name;
} public void setName(String name) { this.name = name;
} public String getPhone() { return phone;
} public void setPhone(String phone) { this.phone = phone;
} public String getMobile() { return mobile;
} public void setMobile(String mobile) { this.mobile = mobile;
} public String getLoginToken() { return loginToken;
} public void setLoginToken(String loginToken) { this.loginToken = loginToken;
} public String getIsStoreAdm() { return isStoreAdm;
} public void setIsStoreAdm(String isStoreAdm) { this.isStoreAdm = isStoreAdm;
} public String getStoreLogo() { return storeLogo;
} public void setStoreLogo(String storeLogo) { this.storeLogo = storeLogo;
}
} 求帮助呀,谢谢大神了。

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答