No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd/jsonpointer
.gitignore
.travis.yml
LICENSE add LICENSE Apr 27, 2017
README.md
go.test.sh chmod +x Feb 22, 2018
jsonpointer.go
jsonpointer_test.go Allow final trailing space to be an identifier Feb 23, 2018

README.md

go-jsonpointer

Build Status Codecov GoDoc Go Report Card

Go implementation of JSON Pointer (RFC6901)

Usage

jsonpointer.Get(obj, pointer)

json := `
{
	"foo": [1,true,2]
}
`
var obj interface{}
json.Unmarshal([]byte(json), &obj)
jsonpointer.Get(obj, "/foo/1") // Should be true

jsonpointer.Set(obj, pointer, newvalue)

json := `
{
	"foo": [1,true,2]
}
`
var obj interface{}
json.Unmarshal([]byte(json), &obj)
jsonpointer.Set(obj, "/foo/1", false)
// obj should be {"foo":[1,false,2]}

jsonpointer.Remove(obj, pointer)

json := `
{
	"foo": [1,true,2]
}
`
var obj interface{}
json.Unmarshal([]byte(json), &obj)
jsonpointer.Remove(obj, "/foo/1")
// obj should be {"foo":[1,2]}

Installation

$ go get github.com/mattn/go-jsonpointer

License

MIT

Author

Yasuhiro Matsumoto (a.k.a mattn)