@@ -185,7 +185,7 @@ func searchKeys(data []byte, keys ...string) int {
185
185
var valueOffset int
186
186
187
187
ArrayEach (data [i :], func (value []byte , dataType ValueType , offset int , err error ) {
188
- if ( curIdx == aIdx ) {
188
+ if curIdx == aIdx {
189
189
valueFound = value
190
190
valueOffset = offset
191
191
}
@@ -344,7 +344,7 @@ func EachKey(data []byte, cb func(int, []byte, ValueType, error), paths ...[]str
344
344
continue
345
345
}
346
346
347
- aIdx , _ := strconv .Atoi (p [level ][1 : len (p [level ]) - 1 ])
347
+ aIdx , _ := strconv .Atoi (p [level ][1 : len (p [level ])- 1 ])
348
348
arrIdxFlags |= bitwiseFlags [aIdx + 1 ]
349
349
pIdxFlags |= bitwiseFlags [pi + 1 ]
350
350
}
@@ -354,10 +354,10 @@ func EachKey(data []byte, cb func(int, []byte, ValueType, error), paths ...[]str
354
354
355
355
var curIdx int
356
356
arrOff , _ := ArrayEach (data [i :], func (value []byte , dataType ValueType , offset int , err error ) {
357
- if ( arrIdxFlags & bitwiseFlags [curIdx + 1 ] != 0 ) {
357
+ if arrIdxFlags & bitwiseFlags [curIdx + 1 ] != 0 {
358
358
for pi , p := range paths {
359
359
if pIdxFlags & bitwiseFlags [pi + 1 ] != 0 {
360
- aIdx , _ := strconv .Atoi (p [level - 1 ][1 : len (p [level - 1 ]) - 1 ])
360
+ aIdx , _ := strconv .Atoi (p [level - 1 ][1 : len (p [level - 1 ])- 1 ])
361
361
362
362
if curIdx == aIdx {
363
363
of := searchKeys (value , p [level :]... )
@@ -571,6 +571,17 @@ func ArrayEach(data []byte, cb func(value []byte, dataType ValueType, offset int
571
571
offset ++
572
572
}
573
573
574
+ nO := nextToken (data [offset :])
575
+ if nO == - 1 {
576
+ return offset , MalformedJsonError
577
+ }
578
+
579
+ offset += nO
580
+
581
+ if data [offset ] == ']' {
582
+ return offset , nil
583
+ }
584
+
574
585
for true {
575
586
v , t , o , e := Get (data [offset :])
576
587
@@ -583,7 +594,7 @@ func ArrayEach(data []byte, cb func(value []byte, dataType ValueType, offset int
583
594
}
584
595
585
596
if t != NotExist {
586
- cb (v , t , offset + o - len (v ), e )
597
+ cb (v , t , offset + o - len (v ), e )
587
598
}
588
599
589
600
if e != nil {
0 commit comments