diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/std/UntypedObjectDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/std/UntypedObjectDeserializer.java index e4af5a0630..3f35982788 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/std/UntypedObjectDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/std/UntypedObjectDeserializer.java @@ -331,10 +331,7 @@ public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, if (_numberDeserializer != null) { return _numberDeserializer.deserialize(p, ctxt); } - if (ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { - return p.getDecimalValue(); - } - return p.getNumberValue(); + return _deserializeFP(p, ctxt); case JsonTokenId.ID_TRUE: return Boolean.TRUE; @@ -402,10 +399,7 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt, Object into if (_numberDeserializer != null) { return _numberDeserializer.deserialize(p, ctxt, intoValue); } - if (ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { - return p.getDecimalValue(); - } - return p.getNumberValue(); + return _deserializeFP(p, ctxt); case JsonTokenId.ID_TRUE: return Boolean.TRUE; case JsonTokenId.ID_FALSE: @@ -747,10 +741,7 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOEx return p.getNumberValue(); // should be optimal, whatever it is case JsonTokenId.ID_NUMBER_FLOAT: - if (ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { - return p.getDecimalValue(); - } - return p.getNumberValue(); + return _deserializeFP(p, ctxt); case JsonTokenId.ID_TRUE: return Boolean.TRUE; @@ -790,10 +781,7 @@ public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, Typ return p.getNumberValue(); case JsonTokenId.ID_NUMBER_FLOAT: - if (ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { - return p.getDecimalValue(); - } - return p.getNumberValue(); + return _deserializeFP(p, ctxt); case JsonTokenId.ID_TRUE: return Boolean.TRUE; @@ -874,6 +862,24 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt, Object into return deserialize(p, ctxt); } + // @since 2.17 + protected Object _deserializeFP(JsonParser p, DeserializationContext ctxt) throws IOException + { + JsonParser.NumberTypeFP nt = p.getNumberTypeFP(); + if (nt == JsonParser.NumberTypeFP.BIG_DECIMAL) { + return p.getDecimalValue(); + } + if (!p.isNaN()) { + if (ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { + return p.getDecimalValue(); + } + } + if (nt == JsonParser.NumberTypeFP.FLOAT32) { + return p.getFloatValue(); + } + return p.getDoubleValue(); + } + protected Object mapArray(JsonParser p, DeserializationContext ctxt) throws IOException { Object value = deserialize(p, ctxt);