Skip to content

mattn/go-jsonpointer

Repository files navigation

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)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published