Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,7 @@ protected JsonObject _deserializeObject(JsonParser p, DeserializationContext ctx
b.addNull(name);
break;
case VALUE_NUMBER_FLOAT:
if (p.getNumberType() == NumberType.BIG_DECIMAL) {
b.add(name, p.getDecimalValue());
} else {
b.add(name, p.getDoubleValue());
}
b.add(name, p.getDecimalValue());
break;
case VALUE_NUMBER_INT:
// very cumbersome... but has to be done
Expand Down Expand Up @@ -183,11 +179,7 @@ protected JsonArray _deserializeArray(JsonParser p, DeserializationContext ctxt)
b.addNull();
break;
case VALUE_NUMBER_FLOAT:
if (p.getNumberType() == NumberType.BIG_DECIMAL) {
b.add(p.getDecimalValue());
} else {
b.add(p.getDoubleValue());
}
b.add(p.getDecimalValue());
break;
case VALUE_NUMBER_INT:
// very cumbersome... but has to be done
Expand Down Expand Up @@ -230,10 +222,7 @@ protected JsonValue _deserializeScalar(JsonParser p, DeserializationContext ctxt
// very cumbersome... but has to be done
{
JsonArrayBuilder b = _builderFactory.createArrayBuilder();
if (p.getNumberType() == NumberType.BIG_DECIMAL) {
return b.add(p.getDecimalValue()).build().get(0);
}
return b.add(p.getDoubleValue()).build().get(0);
return b.add(p.getDecimalValue()).build().get(0);
}
case VALUE_NUMBER_INT:
// very cumbersome... but has to be done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.fasterxml.jackson.databind.node.ObjectNode;

import java.beans.ConstructorProperties;
import java.math.BigDecimal;

public class JsonValueDeserializationTest extends TestBase
{
Expand Down Expand Up @@ -135,4 +136,23 @@ public void testConstructorProperties() throws Exception
assertNull(ob2.obj1);
assertSame(JsonValue.NULL, ob2.obj2);
}

public void testBigInteger() throws Exception
{
final String JSON = "[2e308]";
JsonValue v = MAPPER.readValue(JSON, JsonValue.class);
assertTrue(v instanceof JsonArray);
JsonArray a = (JsonArray) v;
assertEquals(1, a.size());
assertTrue(a.get(0) instanceof JsonNumber);
assertEquals(new BigDecimal("2e308").toBigInteger(), ((JsonNumber) a.get(0)).bigIntegerValue());


// also, should work with explicit type
JsonArray array = MAPPER.readValue(JSON, JsonArray.class);
assertEquals(1, array.size());

// and round-tripping ought to be ok:
assertEquals("[2E+308]", serializeAsString(v));
}
}