Skip to content

Commit 397bc5b

Browse files
committed
some more #611
1 parent 9cc36df commit 397bc5b

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,9 @@ public JsonToken nextToken() throws IOException
780780

781781
// Should we have separate handling for plus? Although it is not allowed per se,
782782
// it may be erroneously used, and could be indicate by a more specific error message.
783+
case '.': // [core#611]:
784+
t = _parseFloatThatStartsWithPeriod();
785+
break;
783786
case '0':
784787
case '1':
785788
case '2':
@@ -845,6 +848,8 @@ private final JsonToken _nextTokenNotInObject(int i) throws IOException
845848

846849
// Should we have separate handling for plus? Although it is not allowed per se,
847850
// it may be erroneously used, and could be indicate by a more specific error message.
851+
case '.': // [core#611]:
852+
return (_currToken = _parseFloatThatStartsWithPeriod());
848853
case '0':
849854
case '1':
850855
case '2':
@@ -1046,6 +1051,9 @@ public String nextFieldName() throws IOException
10461051
case '-':
10471052
t = _parseNegNumber();
10481053
break;
1054+
case '.': // [core#611]:
1055+
t = _parseFloatThatStartsWithPeriod();
1056+
break;
10491057
case '0':
10501058
case '1':
10511059
case '2':
@@ -1164,6 +1172,9 @@ private final void _isNextTokenNameYes(int i) throws IOException
11641172
case '-':
11651173
_nextToken = _parseNegNumber();
11661174
return;
1175+
case '.': // [core#611]:
1176+
_nextToken = _parseFloatThatStartsWithPeriod();
1177+
return;
11671178
case '0':
11681179
case '1':
11691180
case '2':
@@ -1221,6 +1232,9 @@ private final boolean _isNextTokenNameMaybe(int i, SerializableString str) throw
12211232
case '-':
12221233
t = _parseNegNumber();
12231234
break;
1235+
case '.': // [core#611]:
1236+
t = _parseFloatThatStartsWithPeriod();
1237+
break;
12241238
case '0':
12251239
case '1':
12261240
case '2':
@@ -1352,6 +1366,17 @@ public Boolean nextBooleanValue() throws IOException
13521366
/**********************************************************
13531367
*/
13541368

1369+
// @since 2.11, [core#611]
1370+
protected final JsonToken _parseFloatThatStartsWithPeriod() throws IOException
1371+
{
1372+
// [core#611]: allow optionally leading decimal point
1373+
if (!isEnabled(JsonReadFeature.ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS.mappedFeature())) {
1374+
return _handleUnexpectedValue(INT_PERIOD);
1375+
}
1376+
return _parseFloat(_textBuffer.emptyAndGetCurrentSegment(),
1377+
0, INT_PERIOD, false, 0);
1378+
}
1379+
13551380
/**
13561381
* Initial parsing method for number values. It needs to be able
13571382
* to parse enough input to be able to determine whether the
@@ -1538,7 +1563,7 @@ private final int _verifyNoLeadingZeroes() throws IOException
15381563
}
15391564
return ch;
15401565
}
1541-
1566+
15421567
private final JsonToken _parseFloat(char[] outBuf, int outPtr, int c,
15431568
boolean negative, int integerPartLength) throws IOException
15441569
{

0 commit comments

Comments
 (0)