在做登陆功能时候,在json解析中报了以下错误
org.json.JSONException: Unterminated object at character 62 of。。。
这是由于在服务区返回数据字符串时使用response新建json对象
JSONObject jsonObject = new JSONObject(string);
字符串中特殊字符没有进行转义使得在正常生成jsonobject时出错,
json返回
{"data":{"uid":"5796cc0f","phone":"","auth":"0","avatar":"http:\/\/picture-10039861.file.myqcloud.com\/avatar\/f112e22ffc9b38f8.jpg","nickname":"渔民1502286806","level":"1","haokan_id":"10000019","gender":"0"},"state":"0","msg":"请求成功"}
改成以下就ok了
{"data":{"uid":\"5796cc0f\","phone":\"\","auth":\"0\","avatar":\"http:\/\/picture-10039861.file.myqcloud.com\/avatar\/f112e22ffc9b38f8.jpg\","nickname":\"渔民1502286806\","level":\"1\","haokan_id":\"10000019\","gender":\"0\"},"state":\"0\","msg":\"请求成功\"}