json字符串如下: {"time":"2019-08-08 22:03:40.815","source":98,"subject":"(RTM Route)Receive messages ","level":2,"content":"Thread 13 Message:{\r\n \"namespace\": \"DeviceInfoPush\",\r\n \"body\": {\r\n \"homeID\": \"11111\",\r\n \"pushDate\": \"2019-08-08 22:03:32\",\r\n \"device\": {\r\n \"resourceNo\": \"1443227\",\r\n \"isOnline\": \"1\",\r\n \"state\": \"1\",\r\n \"value\": \"C:1|D:1\"\r\n }\r\n }\r\n}","ipAddress":"127.0.0.1"} 调用方法: JSON.parseObject(message); 本地测试没问题,线上用liunx上docker启动就报错: error parse new 以前也没遇见过这种错啊~! 换成1.2.52版本线上就正常解析了。。。 ps:之前用的1.2.47,刚好有漏洞,想升级来着,就升到了1.2.59
Q
[alibaba/fastjson]1.2.59 新错误 error parse new
5
A
回答
5
有试过用格式化工具看下这个json串的格式吗? 我这边使用vscode 的beautify工具格式化后是从这个对象(Thread 13 Message)后面报错的
4
{"time":"2019-08-09 00:11:15.799","source":98,"subject":"(RTM Service)Receive messages ","level":2,"content":"SuperWebSocket receive Message:{\r\n \"namespace\": \"ThinkHome.RTM.DeviceInfoPush\",\r\n \"body\": {\r\n \"homeID\": \"H20190221172143262\",\r\n \"pushDate\": \"2019-08-09 00:11:15\",\r\n \"device\": {\r\n \"resourceNo\": \"1120016\",\r\n \"isOnline\": \"1\",\r\n \"state\": \"0\",\r\n \"value\": \"C:1|I:1|V:80|X:47|D:1|A:0|T:9021\"\r\n }\r\n }\r\n}","ipAddress":"101.200.39.154"}
9
这是粘贴导致转义字符 \ 没了,我用vscode试过了可以, 很奇怪的是用同样的方法,第一次解析会报错,在解析一次就正常了 哦,对了,日志是在多线程环境下解析的,上游是kafka
1
本地把转义字符加上,是没问题的。第一次解析报错日志可否提供呢