A golang implementation of JSONSelect modeled off of @mwhooker's Python implementation
Supports all levels of the JSONSelect specification.
go get github.com/coddingtonbear/go-jsonselect
API documentation is available on Godoc.
JSONSelect offers many different selectors, and describing the full usage is out of the scope of this document, but should you need an overview, consult the JSONSelect documentation.
Selecting all objects having a rating greater than 70 that are subordinate to a key "beers":
package main
import (
"fmt"
"github.com/coddingtonbear/go-jsonselect"
)
var json string = `
{
"beers": [
{
"title": "alpha",
"rating": 50
},
{
"title": "beta",
"rating": 90
}
]
}
`
func main() {
parser, _ := jsonselect.CreateParserFromString(json)
results, _ := parser.GetValues(".beers object:has(.rating:expr(x>70))")
fmt.Print(results)
// Results [map[title: beta rating: 90]]
}