Missing properties when deserializing using a builder class with a non-default constructor and a mutator annotated with @JsonUnwrapped
#1573
Milestone
@JsonUnwrapped
#1573
When deserializing using a builder class with a non-default constructor and any number of mutator methods annotated with @JsonUnwrapped, the
BuilderBasedDeserializer::deserializeUsingPropertyBasedWithUnwrapped
method cuts short the process of adding SettableBeanProperties.The logic dictates that once all properties necessary to construct the builder have been found, the builder is constructed using all known SettableBeanProperties that have been found up to that point in the tokenizing process.
Therefore, in the case that the builder has a single property required for construction, and that property is found anywhere other than at the end of the JSON content, any properties subsequent to the constructor property are not evaluated and are left with their default values.
Given the following classes:
And given the following JSON string:
We will see the following output:
However, if we place the
emp_id
property at the end of the JSON string, we would get the following output:If we were to place
emp_age
andemp_first_name
andemp_last_name
all after theemp_id
property in the JSON string, we would get the following output:The text was updated successfully, but these errors were encountered: