mirror of https://github.com/goccy/go-json.git
Fix skipValue
This commit is contained in:
parent
7421d82c43
commit
7f97aca5e6
|
@ -25,9 +25,16 @@ func skipValue(buf []byte, cursor int64) (int64, error) {
|
|||
braceCount := 0
|
||||
bracketCount := 0
|
||||
buflen := int64(len(buf))
|
||||
start := cursor
|
||||
for {
|
||||
switch buf[cursor] {
|
||||
case '\000':
|
||||
case nul:
|
||||
if start == cursor {
|
||||
return cursor, errUnexpectedEndOfJSON("value of object", cursor)
|
||||
}
|
||||
if braceCount == 0 && bracketCount == 0 {
|
||||
return cursor, nil
|
||||
}
|
||||
return cursor, errUnexpectedEndOfJSON("value of object", cursor)
|
||||
case '{':
|
||||
braceCount++
|
||||
|
@ -40,6 +47,9 @@ func skipValue(buf []byte, cursor int64) (int64, error) {
|
|||
}
|
||||
case ']':
|
||||
bracketCount--
|
||||
if braceCount == 0 && bracketCount == -1 {
|
||||
return cursor, nil
|
||||
}
|
||||
case ',':
|
||||
if bracketCount == 0 && braceCount == 0 {
|
||||
return cursor, nil
|
||||
|
|
|
@ -111,12 +111,19 @@ func (s *stream) skipValue() error {
|
|||
s.skipWhiteSpace()
|
||||
braceCount := 0
|
||||
bracketCount := 0
|
||||
start := s.cursor
|
||||
for {
|
||||
switch s.char() {
|
||||
case nul:
|
||||
if s.read() {
|
||||
continue
|
||||
}
|
||||
if start == s.cursor {
|
||||
return errUnexpectedEndOfJSON("value of object", s.totalOffset())
|
||||
}
|
||||
if braceCount == 0 && bracketCount == 0 {
|
||||
return nil
|
||||
}
|
||||
return errUnexpectedEndOfJSON("value of object", s.totalOffset())
|
||||
case '{':
|
||||
braceCount++
|
||||
|
@ -129,7 +136,7 @@ func (s *stream) skipValue() error {
|
|||
}
|
||||
case ']':
|
||||
bracketCount--
|
||||
if braceCount == 0 && bracketCount == 0 {
|
||||
if braceCount == 0 && bracketCount == -1 {
|
||||
return nil
|
||||
}
|
||||
case ',':
|
||||
|
|
Loading…
Reference in New Issue