From 17d1fcf976d470ddc00ca838016c6f5925373d97 Mon Sep 17 00:00:00 2001 From: Vladimir Grichina Date: Tue, 8 Jan 2019 02:14:16 -0800 Subject: [PATCH] Minor fix to nested objects parsing --- assembly/decoder.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/assembly/decoder.ts b/assembly/decoder.ts index f836367..45430d4 100644 --- a/assembly/decoder.ts +++ b/assembly/decoder.ts @@ -105,6 +105,9 @@ export class JSONDecoder { } private peekChar(): i32 { + if (this.state.readIndex >= this.state.buffer.length) { + return -1; + } return this.state.buffer[this.state.readIndex]; } @@ -129,7 +132,9 @@ export class JSONDecoder { if (this.peekChar() != "{".charCodeAt(0)) { 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.skipWhitespace();