Open TENX-S opened 1 year ago
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) }
Given the following json and jsonpath expression:
$.server[?(@.props.isEncrypt == true)].key
the following code can't achieve the desired result, but jsonpath.com can.