File tree 2 files changed +15
-9
lines changed
2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -49,10 +49,10 @@ func findTokenStart(data []byte, token byte) int {
49
49
}
50
50
51
51
func findKeyStart (data []byte , key string ) (int , error ) {
52
- i := 0
52
+ i := nextToken ( data )
53
53
ln := len (data )
54
- if ln > 0 && (data [0 ] == '{' || data [0 ] == '[' ) {
55
- i = 1
54
+ if ln > 0 && (data [i ] == '{' || data [i ] == '[' ) {
55
+ i + = 1
56
56
}
57
57
var stackbuf [unescapeStackBufSize ]byte // stack-allocated array for allocation-free unescaping of small strings
58
58
Original file line number Diff line number Diff line change @@ -221,6 +221,12 @@ var deleteTests = []DeleteTest{
221
221
path : []string {"" },
222
222
data : `^_�^C^A^@{` ,
223
223
},
224
+ {
225
+ desc : "Issue #150: leading space" ,
226
+ json : ` {"test":"input"}` ,
227
+ path : []string {"test" },
228
+ data : ` {}` ,
229
+ },
224
230
}
225
231
226
232
var setTests = []SetTest {
@@ -989,15 +995,15 @@ var getStringTests = []GetTest{
989
995
isErr : true ,
990
996
},
991
997
{
992
- desc : `empty array index` ,
993
- json : `[""]` ,
994
- path : []string {"[]" },
998
+ desc : `empty array index` ,
999
+ json : `[""]` ,
1000
+ path : []string {"[]" },
995
1001
isFound : false ,
996
1002
},
997
1003
{
998
- desc : `malformed array index` ,
999
- json : `[""]` ,
1000
- path : []string {"[" },
1004
+ desc : `malformed array index` ,
1005
+ json : `[""]` ,
1006
+ path : []string {"[" },
1001
1007
isFound : false ,
1002
1008
},
1003
1009
}
You can’t perform that action at this time.
0 commit comments