Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 353be9d

Browse files
committed
fix #178 do not check leading zero for readDouble
1 parent c1f8950 commit 353be9d

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

‎src/main/java/com/jsoniter/IterImpl.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,6 @@ static final int readInt(final JsonIterator iter, final byte c) throws IOExcepti
393393

394394
static final long readLong(final JsonIterator iter, final byte c) throws IOException {
395395
long ind = IterImplNumber.intDigits[c];
396-
if (ind == 0) {
397-
IterImplForStreaming.assertNotLeadingZero(iter);
398-
return 0;
399-
}
400396
if (ind == IterImplNumber.INVALID_CHAR_FOR_NUMBER) {
401397
throw iter.reportError("readLong", "expect 0~9");
402398
}

‎src/main/java/com/jsoniter/IterImplNumber.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,17 @@ public static final int readInt(final JsonIterator iter) throws IOException {
9191
public static final long readLong(JsonIterator iter) throws IOException {
9292
byte c = IterImpl.nextToken(iter);
9393
if (c == '-') {
94-
return IterImpl.readLong(iter, IterImpl.readByte(iter));
94+
c = IterImpl.readByte(iter);
95+
if (IterImplNumber.intDigits[c] == 0) {
96+
IterImplForStreaming.assertNotLeadingZero(iter);
97+
return 0;
98+
}
99+
return IterImpl.readLong(iter, c);
95100
} else {
101+
if (IterImplNumber.intDigits[c] == 0) {
102+
IterImplForStreaming.assertNotLeadingZero(iter);
103+
return 0;
104+
}
96105
long val = IterImpl.readLong(iter, c);
97106
if (val == Long.MIN_VALUE) {
98107
throw iter.reportError("readLong", "value is too large for long");

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /