Closed aliuygur closed 6 years ago
You can't match all the addresses.name for query, but you can specify one value from addresses
array like:
package main
import (
"fmt"
"github.com/thedevsaddam/gojsonq"
)
func main() {
jq := gojsonq.New().JSONString(jsonStr).From("users").Where("addresses.[0].name", "=", "home")
fmt.Printf("%+v%v", jq.Get(), jq.Error())
}
var jsonStr = `
{
"users": [
{
"name": "jhon",
"addresses": [
{"name": "home"},
{"name": "work"}
]
}
]
}
But you may use Macro to achieve your requirements.
Here is an example of how to create custom macro: Custom Macro function
is there anyway to do it?