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