-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
Given the following json and jsonpath expression:
{
"server": [
{
"key": "op_host",
"props": {
"isEncrypt": true
}
}
]
}
$.server[?(@.props.isEncrypt == true)].key
the following code can't achieve the desired result, but jsonpath.com can.
package main
import (
"encoding/json"
"fmt"
"os"
"github.com/PaesslerAG/jsonpath"
)
func main() {
v := interface{}(nil)
json.Unmarshal([]byte(`{
"server": [
{
"key": "op_host",
"props": {
"isEncrypt": true
}
}
]
}`), &v)
welcome, err := jsonpath.Get(`$.server[?(@.props.isEncrypt == true)].key`, &v)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(welcome)
}

Metadata
Metadata
Assignees
Labels
No labels