Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
enhance null handling to check case n in issue 357
  • Loading branch information
samu-iaco committed Oct 6, 2024
commit 66f290a1bd0f02a935005f807af8c4768a2eb4d7
9 changes: 7 additions & 2 deletions src/main/java/com/jsoniter/IterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,13 @@ public static Any readAny(JsonIterator iter) throws IOException {
skipFixedBytes(iter, 4);
return Any.wrap(false);
case 'n':
skipFixedBytes(iter, 3);
return Any.wrap((Object) null);
if (readByte(iter) == 'u' &&
readByte(iter) == 'l' &&
readByte(iter) == 'l') {
return Any.wrap((Object) null);
} else {
throw iter.reportError("readAny", "expected 'null' but found something else");
}
case '[':
skipArray(iter);
return Any.lazyArray(iter.buf, start, iter.head);
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/com/jsoniter/IterImplForStreaming.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,15 @@ public static Any readAny(JsonIterator iter) throws IOException {
iter.skipStartedAt = -1;
return Any.wrap(false);
case 'n':
skipFixedBytes(iter, 3);
iter.skipStartedAt = -1;
return Any.wrap((Object) null);
if (nextToken(iter) == 'u' &&
nextToken(iter) == 'l' &&
nextToken(iter) == 'l') {

iter.skipStartedAt = -1;
return Any.wrap((Object) null);
} else {
throw iter.reportError("readAny", "expected 'null' but found something else");
}
case '[':
skipArray(iter);
copied = copySkippedBytes(iter);
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/jsoniter/IterImplObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ public static final String readObject(JsonIterator iter) throws IOException {
byte c = IterImpl.nextToken(iter);
switch (c) {
case 'n':
IterImpl.skipFixedBytes(iter, 3);
return null;
if (IterImpl.readByte(iter) == 'u' &&
IterImpl.readByte(iter) == 'l' &&
IterImpl.readByte(iter) == 'l') {
return null;
}
throw iter.reportError("readObject", "expected 'null' but found something else");
case '{':
c = IterImpl.nextToken(iter);
if (c == '"') {
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/com/jsoniter/IterImplSkip.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ public static final void skip(JsonIterator iter) throws IOException {
return;
case 't':
case 'n':
IterImpl.skipFixedBytes(iter, 3); // true or null
return;
if (IterImpl.readByte(iter) == 'u' &&
IterImpl.readByte(iter) == 'l' &&
IterImpl.readByte(iter) == 'l') {
return;
} else {
throw iter.reportError("skip", "expected 'null' but found something else");
}
case 'f':
IterImpl.skipFixedBytes(iter, 4); // false
return;
Expand Down