Top Description Inners Methods
com.fasterxml.jackson.annotation

public @Interface JsonIgnoreProperties

extends Annotation
Annotations
@Target:ANNOTATION_TYPE, TYPE, METHOD, CONSTRUCTOR, FIELD
@Retention:RUNTIME
@JacksonAnnotation
Imports
java.lang.annotation.ElementType, .Retention, .RetentionPolicy, .Target, java.util.*

Annotation that can be used to either suppress serialization of properties (during serialization), or ignore processing of JSON properties read (during deserialization).

Example:

 // to prevent specified fields from being serialized or deserialized
 // (i.e. not include in JSON output; or being set even if they were included)
 @JsonIgnoreProperties({ "internalId", "secretKey" })
 // To ignore any unknown properties in JSON input without exception:
 @JsonIgnoreProperties(ignoreUnknown=true)

Annotation can be applied both to classes and to properties. If used for both, actual set will be union of all ignorals: that is, you can only add properties to ignore, not remove or override. So you can not remove properties to ignore using per-property annotation.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
JsonIgnoreProperties.Value

Helper class used to contain information from a single JsonIgnoreProperties annotation, as well as to provide possible overrides from non-annotation sources.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

True if getters should be allowed (i.e. NOT ignored); false if getters are to be ignored
allowGetters
()

Property that can be enabled to allow "getters" to be used (that is, prevent ignoral of getters for properties listed in value()).

public boolean

Returns:

True if setters should be allowed (i.e. NOT ignored); false if setters are to be ignored
allowSetters
()

Property that can be enabled to allow "setters" to be used (that is, prevent ignoral of setters for properties listed in value()).

public boolean

Returns:

True if any and all unknown properties are to be ignored without exceptions (or other special handling); false otherwise.
ignoreUnknown
()

Property that defines whether it is ok to just ignore any unrecognized properties during deserialization.

public String[]
value()

Names of properties to ignore.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

allowGettersback to summary
public boolean allowGetters()

Property that can be enabled to allow "getters" to be used (that is, prevent ignoral of getters for properties listed in value()). This is commonly set to support defining "read-only" properties; ones for which there is a getter, but no matching setter: in this case, properties should be ignored for deserialization but NOT serialization. Another way to think about this setting is that setting it to `true` will "disable" ignoring of getters.

Default value is `false`, which means that getters with matching names will be ignored.

Returns:boolean

True if getters should be allowed (i.e. NOT ignored); false if getters are to be ignored

Since
2.6
allowSettersback to summary
public boolean allowSetters()

Property that can be enabled to allow "setters" to be used (that is, prevent ignoral of setters for properties listed in value()). This could be used to specify "write-only" properties; ones that should not be serialized out, but that may be provided in for deserialization. Another way to think about this setting is that setting it to `true` will "disable" ignoring of setters.

Default value is `false`, which means that setters with matching names will be ignored.

Returns:boolean

True if setters should be allowed (i.e. NOT ignored); false if setters are to be ignored

Since
2.6
ignoreUnknownback to summary
public boolean ignoreUnknown()

Property that defines whether it is ok to just ignore any unrecognized properties during deserialization. If true, all properties that are unrecognized -- that is, there are no setters or creators that accept them -- are ignored without warnings (although handlers for unknown properties, if any, will still be called) without exception.

Does not have any effect on serialization.

Returns:boolean

True if any and all unknown properties are to be ignored without exceptions (or other special handling); false otherwise.

valueback to summary
public String[] value()

Names of properties to ignore.

com.fasterxml.jackson.annotation back to summary

public Class JsonIgnoreProperties.Value

extends Object
implements JacksonAnnotationValue<JsonIgnoreProperties>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, com.fasterxml.jackson.annotation.JacksonAnnotationValue

Helper class used to contain information from a single JsonIgnoreProperties annotation, as well as to provide possible overrides from non-annotation sources.
Since
2.8

Field Summary

Modifier and TypeField and Description
protected final boolean
protected final boolean
protected final Set<String>
_ignored

Names of properties to ignore.

protected final boolean
protected final boolean
protected static final JsonIgnoreProperties.Value
EMPTY

Default instance has no explicitly ignored fields, does not ignore unknowns, does not explicitly allow getters/setters (that is, ignorals apply to both), but does use merging for combining overrides with base settings

private static final long

Constructor Summary

AccessConstructor and Description
protected
Value(Set<String> ignored, boolean ignoreUnknown, boolean allowGetters, boolean allowSetters, boolean merge)

Method Summary

Modifier and TypeMethod and Description
private static Set<String>
private static boolean
_empty(Set<String> ignored, boolean ignoreUnknown, boolean allowGetters, boolean allowSetters, boolean merge)

private static boolean
private static Set<String>
public static JsonIgnoreProperties.Value
construct(Set<String> ignored, boolean ignoreUnknown, boolean allowGetters, boolean allowSetters, boolean merge)

Factory method that may be used (although is NOT the recommended way) to construct an instance from a full set of properties.

public static JsonIgnoreProperties.Value
empty()

Accessor for default instances which has "empty" settings; that is:

  • No explicitly defined fields to ignore
  • Does not ignore unknown fields
  • Does not "allow" getters if property ignored (that is, ignorals apply to both setter and getter)
  • Does not "allow" setters if property ignored (that is, ignorals apply to both setter and getter)
  • Does use merge when combining overrides to base settings, such that `true` settings for any of the properties results in `true`, and names of fields are combined (union)
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Set<String>
findIgnoredForDeserialization()

Method called to find names of properties to ignore when used for serialization: functionally same as getIgnored if getAllowSetters() is false (that is, there is "allowSetters=false" or equivalent), otherwise returns empty java.util.Set.

public Set<String>
findIgnoredForSerialization()

Method called to find names of properties to ignore when used for serialization: functionally same as getIgnored if getAllowGetters() is false (that is, there is "allowGetters=false" or equivalent), otherwise returns empty java.util.Set.

public static JsonIgnoreProperties.Value
public static JsonIgnoreProperties.Value
public static JsonIgnoreProperties.Value
forIgnoreUnknown(boolean state)

public static JsonIgnoreProperties.Value
public boolean
public boolean
public Set<String>
public boolean
public boolean
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public static JsonIgnoreProperties.Value
merge(JsonIgnoreProperties.Value base, JsonIgnoreProperties.Value overrides)

Helper method that will try to combine values from two Value instances, using one as base settings, and the other as overrides to use instead of base values when defined; base values are only use if override does not specify a value (matching value is null or logically missing).

public static JsonIgnoreProperties.Value
protected Object
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Class<JsonIgnoreProperties>
valueFor()

Implements com.fasterxml.jackson.annotation.JacksonAnnotationValue.valueFor.

Introspection method that may be used to find actual annotation that may be used as the source for value instance.
public JsonIgnoreProperties.Value
public JsonIgnoreProperties.Value
public JsonIgnoreProperties.Value
public JsonIgnoreProperties.Value
withIgnored(String... ignored)

public JsonIgnoreProperties.Value
public JsonIgnoreProperties.Value
public JsonIgnoreProperties.Value
public JsonIgnoreProperties.Value
public JsonIgnoreProperties.Value
public JsonIgnoreProperties.Value
public JsonIgnoreProperties.Value
public JsonIgnoreProperties.Value
withOverrides(JsonIgnoreProperties.Value overrides)

Mutant factory method that merges values of this value with given override values, so that any explicitly defined inclusion in overrides has precedence over settings of this value instance.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

_allowGettersback to summary
protected final boolean _allowGetters
_allowSettersback to summary
protected final boolean _allowSetters
_ignoredback to summary
protected final Set<String> _ignored

Names of properties to ignore.

_ignoreUnknownback to summary
protected final boolean _ignoreUnknown
_mergeback to summary
protected final boolean _merge
EMPTYback to summary
protected static final JsonIgnoreProperties.Value EMPTY

Default instance has no explicitly ignored fields, does not ignore unknowns, does not explicitly allow getters/setters (that is, ignorals apply to both), but does use merging for combining overrides with base settings

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

Valueback to summary
protected Value(Set<String> ignored, boolean ignoreUnknown, boolean allowGetters, boolean allowSetters, boolean merge)

Method Detail

_asSetback to summary
private static Set<String> _asSet(String[] v)
_emptyback to summary
private static boolean _empty(Set<String> ignored, boolean ignoreUnknown, boolean allowGetters, boolean allowSetters, boolean merge)
_equalsback to summary
private static boolean _equals(JsonIgnoreProperties.Value a, JsonIgnoreProperties.Value b)
_mergeback to summary
private static Set<String> _merge(Set<String> s1, Set<String> s2)
constructback to summary
public static JsonIgnoreProperties.Value construct(Set<String> ignored, boolean ignoreUnknown, boolean allowGetters, boolean allowSetters, boolean merge)

Factory method that may be used (although is NOT the recommended way) to construct an instance from a full set of properties. Most users would be better off starting by empty() instance and using `withXxx()`/`withoutXxx()` methods, as this factory method may need to be changed if new properties are added in JsonIgnoreProperties annotation.

emptyback to summary
public static JsonIgnoreProperties.Value empty()

Accessor for default instances which has "empty" settings; that is:

  • No explicitly defined fields to ignore
  • Does not ignore unknown fields
  • Does not "allow" getters if property ignored (that is, ignorals apply to both setter and getter)
  • Does not "allow" setters if property ignored (that is, ignorals apply to both setter and getter)
  • Does use merge when combining overrides to base settings, such that `true` settings for any of the properties results in `true`, and names of fields are combined (union)
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
findIgnoredForDeserializationback to summary
public Set<String> findIgnoredForDeserialization()

Method called to find names of properties to ignore when used for serialization: functionally same as getIgnored if getAllowSetters() is false (that is, there is "allowSetters=false" or equivalent), otherwise returns empty java.util.Set.

findIgnoredForSerializationback to summary
public Set<String> findIgnoredForSerialization()

Method called to find names of properties to ignore when used for serialization: functionally same as getIgnored if getAllowGetters() is false (that is, there is "allowGetters=false" or equivalent), otherwise returns empty java.util.Set.

forIgnoredPropertiesback to summary
public static JsonIgnoreProperties.Value forIgnoredProperties(Set<String> propNames)
forIgnoredPropertiesback to summary
public static JsonIgnoreProperties.Value forIgnoredProperties(String... propNames)
forIgnoreUnknownback to summary
public static JsonIgnoreProperties.Value forIgnoreUnknown(boolean state)
fromback to summary
public static JsonIgnoreProperties.Value from(JsonIgnoreProperties src)
getAllowGettersback to summary
public boolean getAllowGetters()
getAllowSettersback to summary
public boolean getAllowSetters()
getIgnoredback to summary
public Set<String> getIgnored()
getIgnoreUnknownback to summary
public boolean getIgnoreUnknown()
getMergeback to summary
public boolean getMerge()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
mergeback to summary
public static JsonIgnoreProperties.Value merge(JsonIgnoreProperties.Value base, JsonIgnoreProperties.Value overrides)

Helper method that will try to combine values from two Value instances, using one as base settings, and the other as overrides to use instead of base values when defined; base values are only use if override does not specify a value (matching value is null or logically missing). Note that one or both of value instances may be `null`, directly; if both are `null`, result will also be `null`; otherwise never null.

mergeAllback to summary
public static JsonIgnoreProperties.Value mergeAll(JsonIgnoreProperties.Value... values)
Since
2.8
readResolveback to summary
protected Object readResolve()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
valueForback to summary
public Class<JsonIgnoreProperties> valueFor()

Implements com.fasterxml.jackson.annotation.JacksonAnnotationValue.valueFor.

Doc from com.fasterxml.jackson.annotation.JacksonAnnotationValue.valueFor.

Introspection method that may be used to find actual annotation that may be used as the source for value instance.

Returns:Class<JsonIgnoreProperties>

Annotation class for which instances of this value class are created

Annotations
@Override
withAllowGettersback to summary
public JsonIgnoreProperties.Value withAllowGetters()
withAllowSettersback to summary
public JsonIgnoreProperties.Value withAllowSetters()
withIgnoredback to summary
public JsonIgnoreProperties.Value withIgnored(Set<String> ignored)
withIgnoredback to summary
public JsonIgnoreProperties.Value withIgnored(String... ignored)
withIgnoreUnknownback to summary
public JsonIgnoreProperties.Value withIgnoreUnknown()
withMergeback to summary
public JsonIgnoreProperties.Value withMerge()
withoutAllowGettersback to summary
public JsonIgnoreProperties.Value withoutAllowGetters()
withoutAllowSettersback to summary
public JsonIgnoreProperties.Value withoutAllowSetters()
withoutIgnoredback to summary
public JsonIgnoreProperties.Value withoutIgnored()
withoutIgnoreUnknownback to summary
public JsonIgnoreProperties.Value withoutIgnoreUnknown()
withoutMergeback to summary
public JsonIgnoreProperties.Value withoutMerge()
withOverridesback to summary
public JsonIgnoreProperties.Value withOverrides(JsonIgnoreProperties.Value overrides)

Mutant factory method that merges values of this value with given override values, so that any explicitly defined inclusion in overrides has precedence over settings of this value instance. If no overrides exist will return this instance; otherwise new Value with changed inclusion values.