https://github.com/mattn/go-jsonpointer
https://github.com/mattn/go-jsonpointer
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mattn/go-jsonpointer
- Owner: mattn
- License: mit
- Created: 2014-10-30T01:15:23.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-11-28T15:47:22.000Z (over 5 years ago)
- Last Synced: 2025-04-02T04:59:36.003Z (3 months ago)
- Language: Go
- Size: 16.6 KB
- Stars: 96
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-jsonpointer
[](https://travis-ci.org/mattn/go-jsonpointer)
[](https://codecov.io/gh/mattn/go-jsonpointer)
[](http://godoc.org/github.com/mattn/go-jsonpointer)
[](https://goreportcard.com/report/github.com/mattn/go-jsonpointer)Go implementation of JSON Pointer (RFC6901)
## Usage
`jsonpointer.Get(obj, pointer)`
```go
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)`
```go
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)`
```go
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)