diff --git a/common/json/internal/contextjson_120/scanner.go b/common/json/internal/contextjson_120/scanner.go index 4c43f5f9..cfe38711 100644 --- a/common/json/internal/contextjson_120/scanner.go +++ b/common/json/internal/contextjson_120/scanner.go @@ -300,7 +300,7 @@ func stateEndValue(s *scanner, c byte) int { case parseObjectValue: if c == ',' { s.parseState[n-1] = parseObjectKey - s.step = stateBeginString + s.step = stateBeginStringOrEmpty return scanObjectValue } if c == '}' { diff --git a/common/json/internal/contextjson_120/stream.go b/common/json/internal/contextjson_120/stream.go index 355e2eca..42874f27 100644 --- a/common/json/internal/contextjson_120/stream.go +++ b/common/json/internal/contextjson_120/stream.go @@ -407,6 +407,7 @@ func (dec *Decoder) Token() (Token, error) { case '}': if dec.tokenState != tokenObjectStart && dec.tokenState != tokenObjectComma { + if dec.tokenState != tokenObjectStart && dec.tokenState != tokenObjectComma && dec.tokenState != tokenObjectKey { return dec.tokenError(c) } dec.scanp++ @@ -487,7 +488,26 @@ func (dec *Decoder) tokenError(c byte) (Token, error) { // current array or object being parsed. func (dec *Decoder) More() bool { c, err := dec.peek() - return err == nil && c != ']' && c != '}' + //return err == nil && c != ']' && c != '}' + if err != nil { + return false + } + if c == ']' || c == '}' { + return false + } + if c == ',' { + scanp := dec.scanp + dec.scanp++ + c, err = dec.peek() + dec.scanp = scanp + if err != nil { + return false + } + if c == ']' || c == '}' { + return false + } + } + return true } func (dec *Decoder) peek() (byte, error) {