Reputation: 131
I have some fields annotated with @Getter/Setter
. Now I want to use @JsonGetter/JsonSetter
on top of that. Can this be done or do I have to write out the methods to use Jackson-annotations
on them?
class C {
@JsonGetter // Compile error
@Getter
private int count;
}
Upvotes: 2
Views: 1959
Reputation: 40098
@JsonGetter is method level annotation, so you can only add this annotation for methods, Since 1.5
(deprecated since version 1.5) it is deprecated and recommended to use @JsonProperty
@Target(value=METHOD)
@Retention(value=RUNTIME)
@Deprecated
public @interface JsonGetter
Marker annotation that can be used to define a non-static, no-argument value-returning (non-void) method to be used as a "getter" for a logical property, as an alternative to recommended JsonProperty annotation (which was introduced in version 1.1).
Upvotes: 2