Allow jsonpath to start with [ char

pull/282/head
Anton Medvedev 7 months ago
parent 85f07837f3
commit c2251d223e
No known key found for this signature in database

@ -35,6 +35,8 @@ func Split(p string) ([]any, bool) {
state = unknown
case ch == '.':
state = propOrIndex
case ch == '[':
state = index
default:
return path, false
}

@ -77,6 +77,14 @@ func Test_SplitPath(t *testing.T) {
input: ".foo['bar']['baz\\'']",
want: []any{"foo", "bar", "baz\\'"},
},
{
input: "[42]",
want: []any{42},
},
{
input: "[42].foo",
want: []any{42, "foo"},
},
}
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {

Loading…
Cancel
Save