Skip to content

Commit

Permalink
fix Delete() - correct walk throught different level
Browse files Browse the repository at this point in the history
  • Loading branch information
vkd committed Oct 13, 2017
1 parent 812fd63 commit 2b2103c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ func findTokenStart(data []byte, token byte) int {
func findKeyStart(data []byte, key string) (int, error) {
i := 0
ln := len(data)
if ln > 0 && (data[0] == '{' || data[0] == '[') {
i = 1
}
var stackbuf [unescapeStackBufSize]byte // stack-allocated array for allocation-free unescaping of small strings

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

case '[':
i = blockEnd(data[i:], data[i], ']') + i
case '{':
i = blockEnd(data[i:], data[i], '}') + i
}
i++
}
Expand Down

0 comments on commit 2b2103c

Please sign in to comment.