diff --git a/parser.go b/parser.go index d0ec989..76ec02d 100644 --- a/parser.go +++ b/parser.go @@ -499,7 +499,12 @@ func EachKey(data []byte, cb func(int, []byte, ValueType, error), paths ...[]str case '[': var ok bool arrIdxFlags := make(map[int]struct{}) - pIdxFlags := make([]bool, len(paths)) + + pIdxFlags := make([]bool, stackArraySize)[:] + if len(paths) > cap(pIdxFlags) { + pIdxFlags = make([]bool, len(paths))[:] + } + pIdxFlags = pIdxFlags[0:len(paths)] if level < 0 { cb(-1, nil, Unknown, MalformedJsonError)