Configuring Jackson to use field annotations only
Once annotations are placed in fields, you can configure ObjectMapperto use only field annotations, ignoring the annotations of the getters and seters methods:
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
Annotations for Jackson Mixons
, POJO . - , .
( ):
public interface FooMixIn {
@JsonIgnore
String getBar();
}
ObjectMapper, ( ) POJO:
ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT)
.addMixIn(Foo.class, FooMixIn.class);
:
- , , .
- ( , , , ) .
- ( ): (
private, protected,...) .
. .