Skip to content

Commit 2b2103c

Browse files
committed
fix Delete() - correct walk throught different level
1 parent 812fd63 commit 2b2103c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

parser.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ func findTokenStart(data []byte, token byte) int {
5252
func findKeyStart(data []byte, key string) (int, error) {
5353
i := 0
5454
ln := len(data)
55+
if ln > 0 && (data[0] == '{' || data[0] == '[') {
56+
i = 1
57+
}
5558
var stackbuf [unescapeStackBufSize]byte // stack-allocated array for allocation-free unescaping of small strings
5659

5760
if ku, err := Unescape(StringToBytes(key), stackbuf[:]); err == nil {
@@ -94,6 +97,10 @@ func findKeyStart(data []byte, key string) (int, error) {
9497
return keyBegin - 1, nil
9598
}
9699

100+
case '[':
101+
i = blockEnd(data[i:], data[i], ']') + i
102+
case '{':
103+
i = blockEnd(data[i:], data[i], '}') + i
97104
}
98105
i++
99106
}

0 commit comments

Comments
 (0)