@Target(value={ANNOTATION_TYPE,METHOD,CONSTRUCTOR,FIELD}) @Retention(value=RUNTIME) public @interface JsonIgnore
In addition, starting with Jackson 1.9, if this is the only annotation
associated with a property, it will also cause cause the whole
property to be ignored: that is, if setter has this annotation and
getter has no annotations, getter is also effectively ignored.
It is still possible for different accessors to use different
annotations; so if only "getter" is to be ignored, other accessors
(setter or field) would need explicit annotation to prevent
ignoral (usually JsonProperty
).
For example, a "getter" method that would otherwise denote a property (like, say, "getValue" to suggest property "value") to serialize, would be ignored and no such property would be output unless another annotation defines alternative method to use.
Before version 1.9, this annotation worked purely on method-by-method (or field-by-field) basis; annotation on one method or field did not imply ignoring other methods or fields. However, with version 1.9 and above, annotations associated with various accessors (getter, setter, field, constructor parameter) of a logical property are combined; meaning that annotations in one (say, setter) can have effects on all of them (if getter or field has nothing indicating otherwise).
Annotation is usually used just a like a marker annotation, that
is, without explicitly defining 'value' argument (which defaults
to true
): but argument can be explicitly defined.
This can be done to override an existing JsonIgnore by explicitly
defining one with 'false' argument.
Annotation is similar to XmlTransient
Modifier and Type | Optional Element and Description |
---|---|
boolean |
value
Optional argument that defines whether this annotation is active
or not.
|
public abstract boolean value
Copyright © 2008–2016 FasterXML. All rights reserved.