FasterXML / jackson-annotations

Core annotations (annotations that only depend on jackson-core) for Jackson data processor
https://github.com/FasterXML/jackson
Apache License 2.0
1.03k stars 330 forks source link

@JsonAnyGetter can't be used on fields, even though documentation says it can be and @JsonAnySetter can #107

Closed Raniz85 closed 7 years ago

Raniz85 commented 7 years ago

The documentation for JsonAnyGetter states that it can be used on fields (emphasis mine):

Marker annotation that can be used to define a non-static, no-argument method or member field as something of a reverse of JsonAnySetter method

But the code only includes ANNOTATION_TYPE and METHOD.

@JsonAnySetter however also includes FIELD (but doesn't mention that this is valid in the documentation).

cowtowncoder commented 7 years ago

Agreed: should improve handling (and javadocs for @JsonAnySetter -- this was implemented via #1047 for 2.8 and javadocs were not improved). I created

https://github.com/FasterXML/jackson-databind/issues/1458

since there's some work on databind to make this possible, not just annotations (since access from fields differs from methods).

Thank you for reporting this; hoping to implement for 2.9!

cowtowncoder commented 7 years ago

Javadocs updated to reflect actual implementation. Also note somewhat related issue #109 which allows disabling of effects of both annotations (usually using mix-in annotations).

Note that for possible additional support for field-as-any-getter, there is now this:

https://github.com/FasterXML/jackson-databind/issues/1458