Fixes for #2 #3

Manually merged
vitalif merged 2 commits from maxmitti/fast-json-stream:fixes into master 2020-08-18 02:16:21 +03:00
1 changed files with 9 additions and 1 deletions

View File

@ -47,6 +47,10 @@ class JSONStream
$this->offset++; $this->offset++;
$this->skipWhitespace(); $this->skipWhitespace();
$st = $this->buffer[$this->offset] === '}' ? 2 : 1; $st = $this->buffer[$this->offset] === '}' ? 2 : 1;
if ($st == 2)
{
$this->offset++;
}
$this->in[] = [ $st, self::OBJ, NULL, false ]; $this->in[] = [ $st, self::OBJ, NULL, false ];
} }
@ -64,6 +68,10 @@ class JSONStream
$this->offset++; $this->offset++;
$this->skipWhitespace(); $this->skipWhitespace();
$st = $this->buffer[$this->offset] === ']' ? 2 : 1; $st = $this->buffer[$this->offset] === ']' ? 2 : 1;
if ($st == 2)
{
$this->offset++;
}
$this->in[] = [ $st, self::ARR, NULL, false ]; $this->in[] = [ $st, self::ARR, NULL, false ];
} }
@ -119,7 +127,7 @@ class JSONStream
$v = $this->readToken(); $v = $this->readToken();
} while (count($this->in) > $n); } while (count($this->in) > $n);
$value = $v; $value = $v;
return ($this->in[count($this->in)-1][0] == 1); return true;
} }
public function unreadBuffer() public function unreadBuffer()