Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path可能解决方式

来源:互联网 发布:若四阶矩阵a与b相似 编辑:程序博客网 时间:2024/05/19 01:10

Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path:

我这返回的json有以下两个字段:
"delay_arrtime": "-11512",
"delay_deptime": "-3712",
我在解析时:
info.setDelay_deptime(json.optString("delay_deptime"));
info.setDelay_arrtime(json.optString("delay_arrtime"));
用optLong()也是一样

改成optInt()就可以了:
info.setDelay_deptime(json.optInt("delay_deptime"));
info.setDelay_arrtime(json.optInt("delay_arrtime"));

其它的检测及解决方式参考:

(1)http://blog.csdn.net/aaren_jiang/article/details/12849777#java

关于Gson解析的异常,我花费两个小时才调试出来。如果你程序出现以下的异常,有两种可能性:‘

1. 找到一个JSON格式的验证工具,这个网上很多大家可以百度下

2.你的JSON格式验证没有问题,却一直报这个解析错误,请确定你的JSON数据没有多余的空格。这个空格有可能在IO流读取的时候多读了

(2)http://blog.csdn.net/u013290250/article/details/51614490

1.首先第一步,检查你联网的URL是否正确。 
2.第二步,检查你写的模型是否正确。

0 0
原创粉丝点击