杰克逊忽略了嵌套属性

时间:2018-08-23 16:16:06

标签: java json serialization jackson

假设我有要序列化的此类

public class FormattedOutput {
    public Filters filters;
    // and more properties, more methods and classes

    public class Filters {
        public Set<Config> configs;
    }
}

以及不应编辑的此类:

public class Config implements Comparable<Config>, Serializable {
    List<Config> children;
    List<Config> fathers;
    Integer somethingElse;

    public getNotAProperty {
        // Jackson parses it, I don't need/want it
        // it actually causes in infinite recursion and i don't need this in my output
    }
}

从FormattedOutput是否有办法添加一些类似的东西?

@JsonIgnoreProperties({"filters.configs.fathers", "filters.configs.notAProperty"})

很抱歉,如果它是另一个问题的重复,但是除了在Config类元素上直接使用@JsonIgnore来忽略...,我没有找到其他答案...

0 个答案:

没有答案