-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
Hi,
How would one go about to get support for the [@.length - n]
syntax illustrated @ https://goessner.net/articles/JsonPath/
I know that [start:stop]
using negative indices is an ok workaround if we have control over the input. Given that gval and jsonpath is meant for end-users to input business logic it would be nice to expose full jsonpath
engine and not jsonpath minus some features
.
v := interface{}(nil)
json.Unmarshal([]byte(`{
"welcome":{
"message":["Good Morning", "Hello World!"]
}
}`), &v)
welcome, err := jsonpath.Get("$.welcome.message[(@.length -1)]", v)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(welcome)
https://go.dev/play/p/tDVmCrg6_OJ
=>
parsing error: $.welcome.message[(@.length -1)] :1:29 - 1:30 unexpected "-" while scanning parentheses expected ")"
PS. Awesome work with both gval and jsonpath; Amazing libraries!
Metadata
Metadata
Assignees
Labels
No labels