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

@JsonProperty(required=true) not honored during Bean de-serialization #17

Closed Yoztastic closed 11 years ago

Yoztastic commented 11 years ago

I had hoped that annotation of a field with @JsonProperty(required=true) would cause an exception to be thrown during de-serialization if the field was missing from the Json.

But it appears to be ignored.

Is there a work around?

cowtowncoder commented 11 years ago

No, this is only used for decorating JSON schemas, and deserializer does not make any use of it. Since handling of annotations is implemented in databind, there is an RFE here:

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

for possibly adding support; this has been requested, and although Jackson will NOT add general validation of input (that's what Java Bean Validation API is for), simple required check seems like a reasonable minimal check to add.