bug处理记录:com.fasterxml.jackson.core.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 9)): has to be escaped using backslash to be included in string value at [Source:

bug处理记录:com.fasterxml.jackson.core.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 9)): has to be escaped using backslash to be included in string value at [Source:

1. 报错:
com.fasterxml.jackson.core.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 9)): has to be escaped using backslash to be included in string value at [Source: (PushbackInputStream); line: 2, column: 21]

2. 导致原因:
测试时是使用swagger测试接口的,下面的 bin 字段的值是复制过来的,bin 的值表面上看是有 空格 的存在,其实是一些 特殊字符, 删除掉特殊字符就可以解决报错了。

向接口中传递json如下

{
  "bin": "B10-41-03  ",  // 此字段值存在特殊字符问题导致的报错
  "equipment": "RF",
  "invtype": "T",
  "isrecount": 0,
  "uname": "RFShuyy",
  "whnum": "DA1H"
}

3. 总结:
字段的值中,若存在 JsonUtil 无法识别的 特殊字符 时,或是后台接收数据对象的数据结构与传入json不一致导致的无法转换,会出现该报错。
只要仔细对照 接口中参数对象 及 传入的json,就可以解决此bug

原文地址:https://www.cnblogs.com/xiangningdeguang/archive/2022/12/06/16954348.html