Skip to content

Commit f0ef2b7

Browse files
committed
Fix skiping chars after array #31
1 parent 8b65db6 commit f0ef2b7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func searchKeys(data []byte, keys ...string) int {
140140
case '[':
141141
// Do not search for keys inside arrays
142142
arraySkip := blockEnd(data[i:], '[', ']')
143-
i += arraySkip
143+
i += arraySkip - 1
144144
}
145145

146146
i++

parser_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ var getTests = []Test{
151151
isFound: true,
152152
data: `2`,
153153
},
154+
Test{
155+
desc: `no padding + nested + array`,
156+
json: `{"a":{"b":[1,2]},"c":3}`,
157+
path: []string{"c"},
158+
isFound: true,
159+
data: `3`,
160+
},
154161

155162
// Not found key tests
156163
Test{

0 commit comments

Comments
 (0)