Java Jackson忽略嵌套属性

Java Jackson忽略嵌套属性,java,json,serialization,jackson,Java,Json,Serialization,Jackson,假设我有一个要序列化的类 public class FormattedOutput { public Filters filters; // and more properties, more methods and classes public class Filters { public Set<Config> configs; } } 很抱歉,如果这是另一个问题的重复,但除了在配置类元素上直接使用@JsonIgnore来忽略…

假设我有一个要序列化的类

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

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

很抱歉,如果这是另一个问题的重复,但除了在配置类元素上直接使用@JsonIgnore来忽略…

getFathers
上使用
@JsonIgnore
getNotAProperty
方法在
Config
类中,我没有找到任何其他答案。这就是解决这个问题的方法。@RavindraRanwala我已经试过了,而且很有效,但我想知道是否还有其他方法/据我所知,没有
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
    }
}
@JsonIgnoreProperties({"filters.configs.fathers", "filters.configs.notAProperty"})