fasterxml中string字符串转对象json格式单引号错误

踩坑1

  • 在处理fasterxml中string字符串转对象json格式,标准的json都是双引号 (" ")

由于数据是单引号(' ')格式。导致了如下报错,特此记录下

com.fasterxml.jackson.core.JsonParseException: Unexpected character ('s' (code 115)): was expecting double-quote to start field name

com.fasterxml.jackson.databind.ObjectMapper 
mapper = new ObjectMapper();

//增加这行配置
//允许使用单引号,默认是false 
mapper.configure(Feature.ALLOW_SINGLE_QUOTES, true);

mapper.readValue(payload, bean.class);

除了ALLOW_UNQUOTED_FIELD_NAMES,ALLOW_SINGLE_QUOTES还有其它的设置,有用到试试。

你可能感兴趣的:(fasterxml中string字符串转对象json格式单引号错误)