首页 前端知识 JSON解析异常: A JSONObject text must begin with ‘{‘ at 1 [character 2 line 1]

JSON解析异常: A JSONObject text must begin with ‘{‘ at 1 [character 2 line 1]

2024-09-12 23:09:42 前端知识 前端哥 858 835 我要收藏

肯定是json格式有问题,才会导致解析有问题

通过debug发现返回给前端的json字符串如下:

通过JSONUtil.toBean()方法转换为对象时报错,原因是返回的json数据两侧多了一对双引号

解决方法:

若该字段可以为空,使用subString()方法截去双引号即可。

        if (str != null) {
            str = str.substring(1, judgeConfigStr.length() - 1);
        }

转载请注明出处或者链接地址:https://www.qianduange.cn//article/18241.html
标签
评论
发布的文章

关于HTML的知识

2024-09-18 23:09:36

js简单实现轮播图效果

2024-09-18 23:09:36

CSS3美化网页元素

2024-09-18 23:09:27

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!