Spring @JsonIgnore not working

前端 未结 8 1563
终归单人心
终归单人心 2020-12-01 07:46

How can I get @JsonIgnore to work I have a class. And even if I put the annotation there it has no effect on the output. I am using Jackson.

public class Que         


        
8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-01 08:31

    I added @Getter(onMethod_=@JsonIgnore) for boolean.

    import com.fasterxml.jackson.annotation.JsonFormat;
    import com.fasterxml.jackson.annotation.JsonIgnore;
    import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
    
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @JsonIgnoreProperties(ignoreUnknown = true) 
    public class TestClass    {
    
        
         @JsonIgnore 
        private String name;
        
         @Getter(onMethod_=@JsonIgnore) 
        private boolean isValid; 
    
    }
    

提交回复
热议问题