杰克逊:忽略父类属性 [英] Jackson: Ignore parent class properties

查看:646
本文介绍了杰克逊:忽略父类属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在序列化子类时,有什么办法可以告诉Jackson忽略父类的属性吗?

Is there any way I can tell Jackson to ignore properties from parent class while serializing a 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
    }


推荐答案

定义&安培;使用 JSON视图,省略了继承的字段。

Define & use a JSON view which omits the inherited fields.

这篇关于杰克逊:忽略父类属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆