fastjson 双引号json反序列化使用不了自定义的ObjectDeserializer,但单引号可以

kqhtkvqz  于 2021-11-27  发布在  Java
关注(0)|答案(1)|浏览(439)

不可行的示例:
代码:

Jon jon = JSON.parseObject("{\"dStr\":\"         hahahaha        \",\"user\":{\"createtime\":null,\"id\":0,\"username\":\"  asdfsadf  asdf  asdf  \"}}", Jon.class, parserConfig);

结果:
{"dStr":" hahahaha ","user":{"id":0,"username":" asdfsadf asdf asdf "}}
可行的示例:
代码:

Jon jon1 = JSON.parseObject("{'dStr':'         hahahaha        ','user':{'createtime':null,'id':0,'username':'  asdfsadf  asdf  asdf  '}}", Jon.class, parserConfig);

结果:
{"dStr":"hahahaha","user":{"id":0,"username":"asdfsadf asdf asdf"}}

双引号的没进入DefaultFieldDeserializer,单引号的进入了DefaultFieldDeserializer

com.alibaba.fastjson.parser.deserializer.FastjsonASMDeserializer_1_Jon
两个生成的反序列化对象为同一个,但处理结果不一样,望解答

qnzebej0

qnzebej01#

问题未重现,请用最新版本1.2.55试试看

相关问题