Spring @JsonIgnore not working

前端 未结 8 1452
终归单人心
终归单人心 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:39

    In my case JsonIgnore was not working only on dates. Then I understood that was because of @JsonFormat() that I was using to define the format of date. Removing that solved the issue.

    0 讨论(0)
  • 2020-12-01 08:41

    I have finally found a solution. I changed the import statement from

    import com.fasterxml.jackson.annotate.JsonIgnore;  // com. instead of org.
    

    to

    import org.codehaus.jackson.annotate.JsonIgnore;
    

    Basically you have to make sure you are using the same class everywhere.

    0 讨论(0)
提交回复
热议问题