Closed nikitatishin5 closed 1 year ago
I ran into an annotation behavior that is incomprehensible to me.
For example, if I try to deserialize an object with such a constructor, then if the fields are null, everything works and an exception is thrown.
@JsonCreator public Person(String userId, String firstName, String birthDate) { this.userId = userId; this.lastName = lastName; this.birthDate = birthDate; }
But if the constructs look like this
@JsonCreator public Person(@JsonProperty(value = "user_id", required = true) String userId, @JsonProperty(value = "first_name", required = true) String firstName, @JsonProperty(value = "birth_date", required = true) String birthDate ){ this.userId = userId; this.lastName = lastName; this.birthDate = birthDate; }
then no validation occurs and no exception is thrown.
Is this the expected behavior?
Class fields are also annotated with @JsonProperty.
Jackson 2.13.2 version | Java 14
I ran into an annotation behavior that is incomprehensible to me.
For example, if I try to deserialize an object with such a constructor, then if the fields are null, everything works and an exception is thrown.
But if the constructs look like this
then no validation occurs and no exception is thrown.
Is this the expected behavior?
Class fields are also annotated with @JsonProperty.
Jackson 2.13.2 version | Java 14