Direct Field Access
Prior to version 1.2, Jackson only allowed serialization / deserialization of properties inferred by presence of "getter" (getPropertyName) and "setter" (setPropertyName) properties. But starting with 1.2, member fields can also directly represent properties.
By default, a member field can represent a property if it:
Does NOT have associated (and enabled) @JsonIgnore annotation AND
is NOT static or transient AND
- is not a synthetic method (so-called "bridge" methods) created by compiler
and it is either
Public AND Field auto-detection is enabled (annotation @JsonAutoDetect for class includes Method.Field -- this is true by default), OR
Has associated property definition annotation; @JsonProperty, @JsonSerialize or @JsonDeserialize
If so, field in question will define a property. Name of the property is same as that of the field unless explicitly defined by associated @JsonProperty (which takes property name as its 'value').
Name collisions
It is NOT legal for multiple fields to define property with the same logical name. Trying to do so will result in an exception being thrown when trying to construct serializer or deserializer during mapping.
Field properties vs. getters/setters
It IS legal to have both setter/getter and field to define property with the same logical name. If so, only setter (for deserialization) or getter (for serialization) is used, and field is ignored. That is; method access has priority over field access. This can not be changed; to force use of field access, you need to ensure that matching method is ignored (usually using @JsonIgnore annotation).
