Closed barelnir closed 10 years ago
There are no known bugs in @JsonIgnore
handling, and I don't see an immediate problem with the code above.
But since it is not complete, it is possible something else causes it.
Can you include more complete class definition? Also, which Jackson version are you using?
The problem was that I had JAXB annotations on the members. it seems that they override the getter mixin annotations. this was wrong because all annotations should be on the getter so i move those annotations
I also change:
@XmlAccessorType(XmlAccessType.FIELD)
to:
@XmlAccessorType(XmlAccessType.PROPERTY)
in the class because FIELD is wrong.
Ok thanks. Yes; if both field and method have annotations (of same name), method annotations will override ones from fields.
I tried to create an interface that will used as mix-in annotations for jackson.
the annotation @JsonIgnore works for types like String,int,CustomObject but it doesn't work for Collections like Set, List, Map I still get the Collection as part of my JSON output.
I put the @JsonIgnore only on the getter that return the Collection for example:
@JsonIgnore Set getCustomObjects();
I am trying to parse JAXB class so I define the serilizers like this:
objectMapper.setAnnotationIntrospector(AnnotationIntrospector.pair(new JacksonAnnotationIntrospector(), new JaxbAnnotationIntrospector()));
objectMapper.addMixInAnnotations(MainObject.class, MainObjectMixInAnnotations.class);
any idea?