coding++:error Could not read JSON: Unexpected token (START_OBJECT), expected START_ARRAY: need JSON Array to contain As.WRAPPER_ARRAY type information for class java.lang.Object


Spring源码中是使用容器中的ObjectMapper对象进行序列化和反序列化。

当我们将自定义的ObjectMapper对象放入IOC容器中后,会自动覆盖SpringBoot自动装载的ObjectMapper对象。

若是我们在自定义的ObjectMapper中设置了objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);属性。

那么可能会影响我们的@RequestBody反序列化JSON串,

将配置类的 om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); 注释掉.


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM