Jackson异常情况处理

Jackson异常情况处理

不打扰是莪最后的温柔 提交于 2020-03-23 11:00:58
3 月,跳不动了?>>> 1、空值转换-异常情况: Can not instantiate value of type [map type; class java.util.HashMap, [simple type, class java.lang.String] -> [simple type, class java.lang.String]] from JSON String; no single-String constructor/factory method 解决方法,在ObjectMapper配置中增加: ``` mapper.configure(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true) ; 2、转义字符-异常情况: org.codehaus.jackson.JsonParseException: Illegal unquoted character ((CTRL- CHAR, code 9)): has to be escaped using backslash to be included in string value at [Source: java.io.StringReader@10cfc2e3; line: 1, column: 2461] 解决办法