json报错 | com.alibaba.fastjson.JSONException: illegal identifier : pos 1, line 1, column 2
Posted 等茶的茶
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了json报错 | com.alibaba.fastjson.JSONException: illegal identifier : pos 1, line 1, column 2相关的知识,希望对你有一定的参考价值。
将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的主要内容,如果未能解决你的问题,请参考以下文章
json.loads 报错 json.decoder.JSONDecodeError