Jackson: ignore parent class properties

Is there any way to tell Jackson to ignore the properties of the parent class when serializing the child class?

     class Parent {
       private String parentProperty1;
       private String parentProperty2;
       // getter setter
     }

     @IgnoreParentProperties // I am expecting something like this
     class Child extends Parent {
       private String childProperty1;
       // getter setter
     }

+6
source share
2 answers

Define and use a JSON view that omits inherited fields.

+4
source

In addition to views that work well, you can also use @JsonIgnoreProperties to display property names to ignore; it may also include parent properties.

+7
source

Source: https://habr.com/ru/post/904731/


All Articles