Jackson转换泛型List出现错误java.util.LinkedHashMap cannot be cast to com.xxx

ObjectMapper mapper = new ObjectMapper();

mapper.readValue(new File(fileAPI.getRoot(), jsonFileName), Map.class);

当使用Jackson解析具体的bean时,应该使用尽量详尽的本来解析,而使用Map.class、List.class解析时,会对具体的bean解析不出

使用new TypeReference<List<Object>>(){},或者具体的Object.class,

注:Object为具体的解析类

相关文章:

  • 2021-07-12
  • 2021-08-28
  • 2022-12-23
  • 2021-06-02
  • 2021-05-08
  • 2021-07-16
  • 2021-12-02
猜你喜欢
  • 2022-12-23
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案