Skip to content

Commit

Permalink
Add missing overrides wrt FP handling for "untyped" case
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 14, 2024
1 parent 9090762 commit b7ed073
Showing 1 changed file with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b7ed073

Please sign in to comment.