@@ -777,13 +777,13 @@ public final JsonToken nextToken() throws IOException
777
777
break ;
778
778
779
779
case '-' :
780
- t = _parseNegNumber ( );
780
+ t = _parsePossibleNumber ( true );
781
781
break ;
782
782
case '+' :
783
- if (! isEnabled (JsonReadFeature .ALLOW_LEADING_PLUS_SIGN_FOR_NUMBERS .mappedFeature ())) {
784
- t = _handleOddValue ( i );
783
+ if (isEnabled (JsonReadFeature .ALLOW_LEADING_PLUS_SIGN_FOR_NUMBERS .mappedFeature ())) {
784
+ t = _parsePossibleNumber ( false );
785
785
} else {
786
- t = _parsePosNumber ( );
786
+ t = _handleOddValue ( i );
787
787
}
788
788
break ;
789
789
case '.' : // [core#61]]
@@ -980,7 +980,14 @@ public String nextFieldName() throws IOException
980
980
981
981
switch (i ) {
982
982
case '-' :
983
- t = _parseNegNumber ();
983
+ t = _parsePossibleNumber (true );
984
+ break ;
985
+ case '+' :
986
+ if (isEnabled (JsonReadFeature .ALLOW_LEADING_PLUS_SIGN_FOR_NUMBERS .mappedFeature ())) {
987
+ t = _parsePossibleNumber (false );
988
+ } else {
989
+ t = _handleOddValue (i );
990
+ }
984
991
break ;
985
992
case '.' : // [core#61]]
986
993
t = _parseFloatThatStartsWithPeriod ();
@@ -1052,7 +1059,14 @@ private final void _isNextTokenNameYes(int i) throws IOException
1052
1059
_nextToken = JsonToken .VALUE_NULL ;
1053
1060
return ;
1054
1061
case '-' :
1055
- _nextToken = _parseNegNumber ();
1062
+ _nextToken = _parsePossibleNumber (true );
1063
+ return ;
1064
+ case '+' :
1065
+ if (isEnabled (JsonReadFeature .ALLOW_LEADING_PLUS_SIGN_FOR_NUMBERS .mappedFeature ())) {
1066
+ _nextToken = _parsePossibleNumber (false );
1067
+ } else {
1068
+ _nextToken = _handleOddValue (i );
1069
+ }
1056
1070
return ;
1057
1071
case '.' : // [core#61]]
1058
1072
_nextToken = _parseFloatThatStartsWithPeriod ();
@@ -1090,9 +1104,16 @@ protected boolean _isNextTokenNameMaybe(int i, String nameToMatch) throws IOExce
1090
1104
JsonToken t ;
1091
1105
switch (i ) {
1092
1106
case '-' :
1093
- t = _parseNegNumber ( );
1107
+ t = _parsePossibleNumber ( true );
1094
1108
break ;
1095
- case '.' : // [core#61]]
1109
+ case '+' :
1110
+ if (isEnabled (JsonReadFeature .ALLOW_LEADING_PLUS_SIGN_FOR_NUMBERS .mappedFeature ())) {
1111
+ t = _parsePossibleNumber (false );
1112
+ } else {
1113
+ t = _handleOddValue (i );
1114
+ }
1115
+ break ;
1116
+ case '.' : // [core#61]
1096
1117
t = _parseFloatThatStartsWithPeriod ();
1097
1118
break ;
1098
1119
case '0' :
@@ -1156,7 +1177,7 @@ private final JsonToken _nextTokenNotInObject(int i) throws IOException
1156
1177
_matchToken ("null" , 1 );
1157
1178
return (_currToken = JsonToken .VALUE_NULL );
1158
1179
case '-' :
1159
- return (_currToken = _parseNegNumber ( ));
1180
+ return (_currToken = _parsePossibleNumber ( true ));
1160
1181
/* Should we have separate handling for plus? Although
1161
1182
* it is not allowed per se, it may be erroneously used,
1162
1183
* and could be indicated by a more specific error message.
@@ -1456,17 +1477,7 @@ private final JsonToken _parseFloat(int ch, int startPtr, int ptr, boolean neg,
1456
1477
return resetFloat (neg , intLen , fractLen , expLen );
1457
1478
}
1458
1479
1459
- protected final JsonToken _parsePosNumber () throws IOException
1460
- {
1461
- return _parsePossibleNumber (false );
1462
- }
1463
-
1464
- protected final JsonToken _parseNegNumber () throws IOException
1465
- {
1466
- return _parsePossibleNumber (true );
1467
- }
1468
-
1469
- private JsonToken _parsePossibleNumber (final boolean negative ) throws IOException
1480
+ private final JsonToken _parsePossibleNumber (final boolean negative ) throws IOException
1470
1481
{
1471
1482
int ptr = _inputPtr ;
1472
1483
int startPtr = negative ? ptr -1 : ptr ; // to include sign/digit already read
@@ -1725,14 +1736,14 @@ protected JsonToken _handleInvalidNumberStart(int ch, boolean negative) throws I
1725
1736
if ((_features & FEAT_MASK_NON_NUM_NUMBERS ) != 0 ) {
1726
1737
return resetAsNaN (match , negative ? Double .NEGATIVE_INFINITY : Double .POSITIVE_INFINITY );
1727
1738
}
1728
- _reportError ("Non-standard token '" +match +"': enable JsonParser.Feature. ALLOW_NON_NUMERIC_NUMBERS to allow" );
1739
+ _reportError ("Non-standard token '" +match +"': enable `JsonReadFeature. ALLOW_NON_NUMERIC_NUMBERS` to allow" );
1729
1740
} else if (ch == 'n' ) {
1730
1741
String match = negative ? "-Infinity" :"+Infinity" ;
1731
1742
_matchToken (match , 3 );
1732
1743
if ((_features & FEAT_MASK_NON_NUM_NUMBERS ) != 0 ) {
1733
1744
return resetAsNaN (match , negative ? Double .NEGATIVE_INFINITY : Double .POSITIVE_INFINITY );
1734
1745
}
1735
- _reportError ("Non-standard token '" +match +"': enable JsonParser.Feature. ALLOW_NON_NUMERIC_NUMBERS to allow" );
1746
+ _reportError ("Non-standard token '" +match +"': enable `JsonReadFeature. ALLOW_NON_NUMERIC_NUMBERS` to allow" );
1736
1747
}
1737
1748
}
1738
1749
reportUnexpectedNumberChar (ch , "expected digit (0-9) to follow minus sign, for valid numeric value" );
@@ -2000,14 +2011,14 @@ protected JsonToken _handleOddValue(int i) throws IOException
2000
2011
if ((_features & FEAT_MASK_NON_NUM_NUMBERS ) != 0 ) {
2001
2012
return resetAsNaN ("NaN" , Double .NaN );
2002
2013
}
2003
- _reportError ("Non-standard token 'NaN': enable JsonParser.Feature. ALLOW_NON_NUMERIC_NUMBERS to allow" );
2014
+ _reportError ("Non-standard token 'NaN': enable `JsonReadFeature. ALLOW_NON_NUMERIC_NUMBERS` to allow" );
2004
2015
break ;
2005
2016
case 'I' :
2006
2017
_matchToken ("Infinity" , 1 );
2007
2018
if ((_features & FEAT_MASK_NON_NUM_NUMBERS ) != 0 ) {
2008
2019
return resetAsNaN ("Infinity" , Double .POSITIVE_INFINITY );
2009
2020
}
2010
- _reportError ("Non-standard token 'Infinity': enable JsonParser.Feature. ALLOW_NON_NUMERIC_NUMBERS to allow" );
2021
+ _reportError ("Non-standard token 'Infinity': enable `JsonReadFeature. ALLOW_NON_NUMERIC_NUMBERS` to allow" );
2011
2022
break ;
2012
2023
case '+' : // note: '-' is taken as number
2013
2024
if (_inputPtr >= _inputEnd ) {
0 commit comments