Skip to content

coddingtonbear/go-jsonselect

Repository files navigation

Build Status GoDoc

go-jsonselect

A golang implementation of JSONSelect modeled off of @mwhooker's Python implementation

Supports all levels of the JSONSelect specification.

Installation

go get github.com/coddingtonbear/go-jsonselect

Usage

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.

Example

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]]
}

About

JSONSelect implementation in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages