com.alibaba.fastjson.JSONException: field null expect ‘[‘, but {, pos 1, line 1,
fastjson
FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
项目地址:https://gitcode.com/gh_mirrors/fastj/fastjson
免费下载资源
·
json字符串 转 List 对象时出现如下异常:
com.alibaba.fastjson.JSONException: field null expect '[', but {, pos 1, line 1, column 2{。。。。。
at com.alibaba.fastjson.parser.DefaultJSONParser.parseArray(DefaultJSONParser.java:741)
java实现的后台逻辑:
String tasksInfos = getMapValueToString(params, "TASKS");
List<String> tasks = JSONArray.parseArray(tasksInfos, String.class);
经过查文档,上面java的实现逻辑是可行的,所以下面来看 json格式:
{
"SINOREQUEST": {
"PARAMDATA": {
"TASKS": {
"TASK_NO": "1606807852",
"NUMBERS": [{
"NUMBER_TYPE": "3",
"NUMBER": "1620275105",
"TEMPLATE_ID": "734"
}]
}
}
}
}
这时就发现问题了,TASKS 参数在解析的时候是作为数组的,但是json里面是普通json对象,所以会出现文章开头的异常。
GitHub 加速计划 / fastj / fastjson
25.69 K
6.51 K
下载
FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
最近提交(Master分支:3 个月前 )
c942c834 - 1 年前
5bc4709b - 1 年前
更多推荐
已为社区贡献2条内容
所有评论(0)