-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Milestone
Description
Describe the bug
When deserializing a float value to a structure nested in JsonUnwrapped and JsonAnySetter, the float value becomes a BigDecimal instead of Double (USE_BIG_DECIMAL_FOR_FLOATS is left to its default setting).
Version information
2.12.4
To Reproduce
@Test
public void test() throws JsonParseException, JsonMappingException, IOException {
ObjectMapper mapper = new ObjectMapper();
Holder holder = mapper.readValue("{\"value1\": -60.0, \"value2\": -60.0}", Holder.class);
assertEquals(Double.class, holder.value1.getClass());
assertEquals(Double.class, holder.holder2.data.get("value2").getClass());
}
public static class Holder {
private Object value1;
@JsonUnwrapped private Holder2 holder2;
public Object getValue1() {
return value1;
}
public void setValue1(Object value1) {
this.value1 = value1;
}
}
public static class Holder2 {
private Map<String, Object> data = new HashMap<>();
@JsonAnyGetter
public Map<String, Object> getData() {
return data;
}
@JsonAnySetter
public void setAny(String key, Object value) {
data.put(key, value);
}
}
Expected behavior
Would still expect a Double here.
Metadata
Metadata
Assignees
Labels
No labels