Skip to content

unexpected json path cause panic #5

@LuShan123888

Description

@LuShan123888

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/go/pkg/mod/github.com/mdaverde/jsonpath@v0.2.1/jsonpath.go:34 +0x35c
github.com/mdaverde/jsonpath.Get({0x10106d060, 0x1400000e028}, {0x10104ada3?, 0x0?})
        /Users/go/pkg/mod/github.com/mdaverde/jsonpath@v0.2.1/jsonpath.go:100 +0x30
main.main()
        /Users/Go/main.go:9 +0x70

Process finished with the exit code 2

Please consider this on urgent basis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions