Minor fix to nested objects parsing

This commit is contained in:
Vladimir Grichina 2019-01-08 02:14:16 -08:00
parent f3800cc7d7
commit 17d1fcf976

View File

@ -105,6 +105,9 @@ export class JSONDecoder<JSONHandlerT extends JSONHandler> {
} }
private peekChar(): i32 { private peekChar(): i32 {
if (this.state.readIndex >= this.state.buffer.length) {
return -1;
}
return this.state.buffer[this.state.readIndex]; return this.state.buffer[this.state.readIndex];
} }
@ -129,7 +132,9 @@ export class JSONDecoder<JSONHandlerT extends JSONHandler> {
if (this.peekChar() != "{".charCodeAt(0)) { if (this.peekChar() != "{".charCodeAt(0)) {
return false; return false;
} }
if (this.handler.pushObject(this.state.lastKey)) { let key = this.state.lastKey;
this.state.lastKey = null;
if (this.handler.pushObject(key)) {
this.readChar(); this.readChar();
this.skipWhitespace(); this.skipWhitespace();