Skip to content

Instantly share code, notes, and snippets.

@thedevsaddam
Created July 10, 2018 16:52
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/da507b7acfab73e2a326c77096d761fa to your computer and use it in GitHub Desktop.
Save thedevsaddam/da507b7acfab73e2a326c77096d761fa to your computer and use it in GitHub Desktop.
jsonq usages of Sum 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).Sum("price")
fmt.Println(res)
// output: 3900
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment