@Target(value={ANNOTATION_TYPE,METHOD,CONSTRUCTOR,FIELD}) @Retention(value=RUNTIME) public @interface JsonIgnore
JsonCreator
-annotated constructor or factory method])
is to be ignored by introspection-based
serialization and deserialization functionality.
Annotation only needs to be added to one of the accessors (often
getter method, but may be setter, field or creator parameter),
if the complete removal of the property is desired.
However: if only particular accessor is to be ignored (for example,
when ignoring one of potentially conflicting setter methods),
this can be done by annotating other not-to-be-ignored accessors
with JsonProperty
(or its equivalents). This is considered
so-called "split property" case and allows definitions of
"read-only" (read from input into POJO) and "write-only" (write
in output but ignore on output)
NOTE! As Jackson 2.6, there is a new and improved way to define
`read-only` and `write-only` properties, using
JsonProperty.access()
annotation: this is recommended over
use of separate JsonIgnore
and JsonProperty
annotations.
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.
When ignoring the whole property, the default behavior if encountering
such property in input is to ignore it without exception; but if there
is a JsonAnySetter
it will be called instead. Either way,
no exception will be thrown.
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: either in a sub-class, or by
using "mix-in annotations".
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–2021 FasterXML. All rights reserved.