@@ -410,6 +410,7 @@ protected final ContainerNode<?> deserializeContainerNonRecursive(JsonParser p,
410
410
throws IOException
411
411
{
412
412
ContainerNode <?> curr = root ;
413
+ final int intCoercionFeats = ctxt .getDeserializationFeatures () & F_MASK_INT_COERCIONS ;
413
414
414
415
outer_loop :
415
416
while (true ) {
@@ -436,7 +437,7 @@ protected final ContainerNode<?> deserializeContainerNonRecursive(JsonParser p,
436
437
value = nodeFactory .textNode (p .getText ());
437
438
break ;
438
439
case JsonTokenId .ID_NUMBER_INT :
439
- value = _fromInt (p , ctxt , nodeFactory );
440
+ value = _fromInt (p , intCoercionFeats , nodeFactory );
440
441
break ;
441
442
case JsonTokenId .ID_NUMBER_FLOAT :
442
443
value = _fromFloat (p , ctxt , nodeFactory );
@@ -492,7 +493,7 @@ protected final ContainerNode<?> deserializeContainerNonRecursive(JsonParser p,
492
493
currArray .add (nodeFactory .textNode (p .getText ()));
493
494
continue arrayLoop ;
494
495
case JsonTokenId .ID_NUMBER_INT :
495
- currArray .add (_fromInt (p , ctxt , nodeFactory ));
496
+ currArray .add (_fromInt (p , intCoercionFeats , nodeFactory ));
496
497
continue arrayLoop ;
497
498
case JsonTokenId .ID_NUMBER_FLOAT :
498
499
currArray .add (_fromFloat (p , ctxt , nodeFactory ));
@@ -568,6 +569,25 @@ protected final JsonNode deserializeRareScalar(JsonParser p, DeserializationCont
568
569
return (JsonNode ) ctxt .handleUnexpectedToken (handledType (), p );
569
570
}
570
571
572
+ protected final JsonNode _fromInt (JsonParser p , int coercionFeatures ,
573
+ JsonNodeFactory nodeFactory ) throws IOException
574
+ {
575
+ if (coercionFeatures != 0 ) {
576
+ if (DeserializationFeature .USE_BIG_INTEGER_FOR_INTS .enabledIn (coercionFeatures )) {
577
+ return nodeFactory .numberNode (p .getBigIntegerValue ());
578
+ }
579
+ return nodeFactory .numberNode (p .getLongValue ());
580
+ }
581
+ final JsonParser .NumberType nt = p .getNumberType ();
582
+ if (nt == JsonParser .NumberType .INT ) {
583
+ return nodeFactory .numberNode (p .getIntValue ());
584
+ }
585
+ if (nt == JsonParser .NumberType .LONG ) {
586
+ return nodeFactory .numberNode (p .getLongValue ());
587
+ }
588
+ return nodeFactory .numberNode (p .getBigIntegerValue ());
589
+ }
590
+
571
591
protected final JsonNode _fromInt (JsonParser p , DeserializationContext ctxt ,
572
592
JsonNodeFactory nodeFactory ) throws IOException
573
593
{
0 commit comments