Skip to content

Commit c3a9b5e

Browse files
committed
more work for #611
1 parent 4cec80a commit c3a9b5e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/main/java/com/fasterxml/jackson/core/json/ReaderBasedJsonParser.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,9 @@ public final JsonToken nextToken() throws IOException
757757
*/
758758
t = _parseNegNumber();
759759
break;
760+
case '.': // [core#61]]
761+
t = _parseFloatThatStartsWithPeriod();
762+
break;
760763
case '0':
761764
case '1':
762765
case '2':
@@ -950,6 +953,9 @@ public String nextFieldName() throws IOException
950953
case '-':
951954
t = _parseNegNumber();
952955
break;
956+
case '.': // [core#61]]
957+
t = _parseFloatThatStartsWithPeriod();
958+
break;
953959
case '0':
954960
case '1':
955961
case '2':
@@ -1019,6 +1025,9 @@ private final void _isNextTokenNameYes(int i) throws IOException
10191025
case '-':
10201026
_nextToken = _parseNegNumber();
10211027
return;
1028+
case '.': // [core#61]]
1029+
_nextToken = _parseFloatThatStartsWithPeriod();
1030+
return;
10221031
case '0':
10231032
case '1':
10241033
case '2':
@@ -1054,6 +1063,9 @@ protected boolean _isNextTokenNameMaybe(int i, String nameToMatch) throws IOExce
10541063
case '-':
10551064
t = _parseNegNumber();
10561065
break;
1066+
case '.': // [core#61]]
1067+
t = _parseFloatThatStartsWithPeriod();
1068+
break;
10571069
case '0':
10581070
case '1':
10591071
case '2':
@@ -1120,6 +1132,8 @@ private final JsonToken _nextTokenNotInObject(int i) throws IOException
11201132
* it is not allowed per se, it may be erroneously used,
11211133
* and could be indicated by a more specific error message.
11221134
*/
1135+
case '.': // [core#61]]
1136+
return (_currToken = _parseFloatThatStartsWithPeriod());
11231137
case '0':
11241138
case '1':
11251139
case '2':
@@ -1258,6 +1272,16 @@ public final Boolean nextBooleanValue() throws IOException
12581272
/**********************************************************
12591273
*/
12601274

1275+
// @since 2.11, [core#611]
1276+
protected final JsonToken _parseFloatThatStartsWithPeriod() throws IOException
1277+
{
1278+
// [core#611]: allow optionally leading decimal point
1279+
if (!isEnabled(JsonReadFeature.ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS.mappedFeature())) {
1280+
return _handleOddValue('.');
1281+
}
1282+
return _parseFloat(INT_PERIOD, _inputPtr-1, _inputPtr, false, 0);
1283+
}
1284+
12611285
/**
12621286
* Initial parsing method for number values. It needs to be able
12631287
* to parse enough input to be able to determine whether the

0 commit comments

Comments
 (0)