码迷,mamicode.com
首页 > Web开发 > 详细

json报错 | com.alibaba.fastjson.JSONException: illegal identifier : \pos 1, line 1, column 2

时间:2020-07-21 14:01:52      阅读:452      评论:0      收藏:0      [点我收藏+]

标签:解决方案   inter   join   object   $$   lib   ati   方案   except   

将json字符串处理对json对象时报错如下:

com.alibaba.fastjson.JSONException: illegal identifier : \pos 1, line 1, column 2
at com.alibaba.fastjson.parser.JSONLexerBase.scanSymbolUnQuoted(JSONLexerBase.java:830) ~[fastjson-1.2.59.jar:?]
	at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:286) ~[fastjson-1.2.59.jar:?]
	at com.alibaba.fastjson.parser.DefaultJSONParser.parse(DefaultJSONParser.java:1394) ~[fastjson-1.2.59.jar:?]
	at com.alibaba.fastjson.parser.DefaultJSONParser.parse(DefaultJSONParser.java:1360) ~[fastjson-1.2.59.jar:?]
	at com.alibaba.fastjson.JSON.parse(JSON.java:165) ~[fastjson-1.2.59.jar:?]
	at com.alibaba.fastjson.JSON.parse(JSON.java:175) ~[fastjson-1.2.59.jar:?]
	at com.alibaba.fastjson.JSON.parse(JSON.java:144) ~[fastjson-1.2.59.jar:?]
	at com.alibaba.fastjson.JSON.parseObject(JSON.java:236) ~[fastjson-1.2.59.jar:?]
	at com.fline.zjsecurity.mgmt.service.impl.DecryptTaskMgmtServiceImpl.decryptInterfaceData(DecryptTaskMgmtServiceImpl.java:359) ~[classes/:?]
	at com.fline.zjsecurity.mgmt.service.impl.DecryptTaskMgmtServiceImpl.decryptData(DecryptTaskMgmtServiceImpl.java:195) ~[classes/:?]
	at com.fline.zjsecurity.mgmt.service.impl.DecryptTaskMgmtServiceImpl$$FastClassBySpringCGLIB$$6155c3a7.invoke(<generated>) ~[classes/:?]
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	……

原字符串为:{\"AAC001\":\"d24b8cf9a7933142\",\"AAC003\":\"a9d24c17fa430a9\",\"AAC004\":\"6fabd7627c8de65f8336eef02fd09d1b80b00000058009558678838c4405c06\"}

报错原因是,在json反序列化时存在转义字符。
解决方案:在处理字符串之前,先将字符串去除转义 StringEscapeUtils.unescapeJava(String data)

json报错 | com.alibaba.fastjson.JSONException: illegal identifier : \pos 1, line 1, column 2

标签:解决方案   inter   join   object   $$   lib   ati   方案   except   

原文地址:https://www.cnblogs.com/waiting-ying/p/13354352.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!