• 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)

  • 相关阅读:
    恢复spark挂掉的节点
    启动spark集群
    记录一下SparkStreaming中因为使用redis做数据验证而导致数据结果不对的问题
    ps -aux与ps -ef
    Operation category READ is not supported in state standby
    spark web ui中的skipped的含义
    关于spark ui中executor显示的内存量与设置的内存量不符的问题
    flume修改配置文件
    maven中的各种问题
    java 的集合框架
  • 原文地址:https://www.cnblogs.com/waiting-ying/p/13354352.html
Copyright © 2020-2023  润新知