jsonpath
jsonpath copied to clipboard
unexpected json path cause panic
Hello, Thanks much for the awesome API. It is helping me a lot.
When I call the jsonpath.get function with the following parameters, the program appears panic instead of returning the error through err.
func main() {
data := make(map[string]any)
_, err := jsonpath.Get(&data, `[["a","a"],["b","b"],["c","c.c"],["d.d","d.d"]`)
if err != nil {
print(err)
}
}
Result:
panic: runtime error: slice bounds out of range [5:2]
goroutine 1 [running]:
github.com/mdaverde/jsonpath.tokenizePath({0x10104ada3, 0x31})
/Users/bytedance/go/pkg/mod/github.com/mdaverde/[email protected]/jsonpath.go:34 +0x35c
github.com/mdaverde/jsonpath.Get({0x10106d060, 0x1400000e028}, {0x10104ada3?, 0x0?})
/Users/bytedance/go/pkg/mod/github.com/mdaverde/[email protected]/jsonpath.go:100 +0x30
main.main()
/Users/bytedance/go/src/code.byted.org/lushan/Go/main.go:9 +0x70
Process finished with the exit code 2
Please consider this on urgent basis.