Skip to content

Instantly share code, notes, and snippets.

@thedevsaddam
Created July 10, 2018 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thedevsaddam/dbb57251241c987fd5674050247ab983 to your computer and use it in GitHub Desktop.
Save thedevsaddam/dbb57251241c987fd5674050247ab983 to your computer and use it in GitHub Desktop.
gojsonq query data using Where and OrWhere method
package main
import (
"fmt"
"github.com/thedevsaddam/gojsonq"
)
func main() {
jq := gojsonq.New().File("./sample-data.json")
res := jq.From("vendor.items").Where("price", ">", 1200).OrWhere("id", "=", nil).Get()
fmt.Println(res)
// output: [map[price:1350 id:1 name:MacBook Pro 13 inch retina] map[id:2 name:MacBook Pro 15 inch retina price:1700] map[id:<nil> name:HP core i3 SSD price:850]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment