https://github.com/qri-io/jsonpointer
golang implementation of IETF RFC6901: https://tools.ietf.org/html/rfc6901
https://github.com/qri-io/jsonpointer
golang ietf json
Last synced: 18 days ago
JSON representation
golang implementation of IETF RFC6901: https://tools.ietf.org/html/rfc6901
- Host: GitHub
- URL: https://github.com/qri-io/jsonpointer
- Owner: qri-io
- License: mit
- Created: 2018-01-13T17:14:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-07T12:57:34.000Z (almost 5 years ago)
- Last Synced: 2025-03-26T03:11:13.394Z (about 1 month ago)
- Topics: golang, ietf, json
- Language: Go
- Size: 14.6 KB
- Stars: 16
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://qri.io)
[](http://godoc.org/github.com/qri-io/jsonpointer)
[](./LICENSE)
[](https://codecov.io/gh/qri-io/jsonpointer)
[](https://circleci.com/gh/qri-io/jsonpointer)
[](https://goreportcard.com/report/github.com/qri-io/jsonpointer)# jsonpointer
golang implementation of [IETF RFC6901](https://tools.ietf.org/html/rfc6901):
_JSON Pointer defines a string syntax for identifying a specific value within a JavaScript Object Notation (JSON) document._### Installation
install with:
`go get -u github.com/qri-io/jsonpointer`### Usage
Here's a quick example pulled from the [godoc](https://godoc.org/github.com/qri-io/jsonpointer):```go
import (
"encoding/json"
"fmt"
"github.com/qri-io/jsonpointer"
)var document = []byte(`{
"foo": {
"bar": {
"baz": [0,"hello!"]
}
}
}`)func main() {
parsed := map[string]interface{}{}
// be sure to handle errors in real-world code!
json.Unmarshal(document, &parsed)// parse a json pointer. Pointers can also be url fragments
// the following are equivelent pointers:
// "/foo/bar/baz/1"
// "#/foo/bar/baz/1"
// "http://example.com/document.json#/foo/bar/baz/1"
ptr, _ := jsonpointer.Parse("/foo/bar/baz/1")// evaluate the pointer against the document
// evaluation always starts at the root of the document
got, _ := ptr.Eval(parsed)fmt.Println(got)
// Output: hello!
}```
### License
MIT### Issues & Contributions
Contributions & Issues are more than welcome! Everything happens over on this repo's [github page](https://github.com/qri-io/jsonpointer)