-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
to-evaluateIssue that has been received but not yet evaluatedIssue that has been received but not yet evaluated
Milestone
Description
Search before asking
- I searched in the issues and found nothing similar.
Describe the bug
Deserialization doesn't work correctly on Double/Float fields after processing BigDecimal's wrapper used in conjunction with @JsonCreator annotation.
Version Information
2.18.2
Reproduction
public class DeserializationIssueCheck {
public static void main(String[] args) throws Exception {
DeserializationIssue issue = new ObjectMapper()
.readValue("{\"decimalHolder\":100.00,\"number\":50}", DeserializationIssue.class);
Logger.getLogger(DeserializationIssueCheck.class.getName())
.warning("issue.number is incorrect: " + issue.number); // WARNING: issue.number is incorrect: 100.0
}
public static class DeserializationIssue {
public DecimalHolder decimalHolder;
public Double number;
}
public static class DecimalHolder {
public BigDecimal value;
public DecimalHolder(BigDecimal value) {
this.value = value;
}
@JsonCreator
public static DecimalHolder of(BigDecimal value) {
return new DecimalHolder(value);
}
}
}
Expected behavior
Objects are correctly deserialized
Additional context
No response
Metadata
Metadata
Assignees
Labels
to-evaluateIssue that has been received but not yet evaluatedIssue that has been received but not yet evaluated