Java IDEA jackson序列化——查询父子类返回 亲测可行

Java IDEA jackson序列化——查询父子类返回 亲测可行

    • 参考

  1. 把父类封装在一个对象中返回Response,SiModelDo–BaseObject(各子类)
  2. 直接返回父类,不包含Response一层List;

直接返回可以 或者对象内包一层

@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS,include = JsonTypeInfo.As.PROPERTY,property = "@class")

Java IDEA jackson序列化——查询父子类返回 亲测可行_第1张图片

Java IDEA jackson序列化——查询父子类返回 亲测可行_第2张图片

参考

  • https://blog.csdn.net/lu520zxcv/article/details/124604787
  • https://stackoverflow.com/questions/61647272/missing-type-id-when-trying-to-resolve-subtype-of-simple-type-missing-type-id-p
  • https://stackoverflow.com/questions/30362446/deserialize-json-with-jackson-into-polymorphic-types-a-complete-example-is-giv
  • https://blog.csdn.net/w_monster/article/details/121616018
  • https://stackoverflow.com/questions/24263904/deserializing-polymorphic-types-with-jackson-based-on-the-presence-of-a-unique-p/50013090#50013090
  • https://stackoverflow.com/questions/57366190/jackson-3-1-1-missing-type-id-of-subtype-exception-for-polymorphic-type-of-list

你可能感兴趣的:(JAVA,IDEA,java)