jackson解析0开头的纯数字的字符串报错问题浅析

已解决

方案:
序列化方式:json-simple
入参序列化方法:String s = JacksonUtils.originalSerialize(orderUid);

1、首先提供了修改配置:

spring:
  jackson:
    parser:
      allow-numeric-leading-zeros: true

2、最开始没生效
JacksonAutoConfiguration 这个类没有被加工成bean
在启动类上加了包扫描路径

@ComponentScan(basePackages = {
"org.springframework.boot.autoconfigure.jackson"
})

配置生效了

3、但是泛化调用的时候还是报错

cause:Invalid numeric value: Leading zeroes not allowed
 at [Source: (String)"017207106537608402920969100000"; line: 1, column: 2]
com.fasterxml.jackson.core.JsonParseException: Invalid numeric value: Leading zeroes not allowed
 at [Source: (String)"017207106537608402920969100000"; line: 1, column: 2]
	at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1798) ~[jackson-core-2.9.3.jar:2.9.3]
	at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:663) ~[jackson-core-2.9.3.jar:2.9.3]
	at com.fasterxml.jackson.core.base.ParserMinimalBase.reportInvalidNumber(ParserMinimalBase.java:539) ~[jackson-core-2.9.3.jar:2.9.3]
	at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._verifyNLZ2(ReaderBasedJsonParser.java:1579) ~[jackson-core-2.9.3.jar:2.9.3]
	at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._verifyNoLeadingZeroes(ReaderBasedJsonParser.java:1566) ~[jackson-core-2.9.3.jar:2.9.3]
	at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._parseNumber2(ReaderBasedJsonParser.java:1439) ~[jackson-core-2.9.3.jar:2.9.3]
	at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._parsePosNumber(ReaderBasedJsonParser.java:1264) ~[jackson-core-2.9.3.jar:2.9.3]
	at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:744) ~[jackson-core-2.9.3.jar:2.9.3]

4、断点打到抛异常的地方
在这里插入图片描述
jackson解析0开头的纯数字的字符串报错问题浅析_第1张图片
在这里插入图片描述
jackson解析0开头的纯数字的字符串报错问题浅析_第2张图片
mask是一个固定值
所以变量就在features

flags & mask 位与运算,全为1才为1,其余为零,

你可能感兴趣的:(异常)