Skip to content

Repository files navigation

QriGoDocLicenseCodecovCIGo Report Card

jsonpointer

golang implementation of IETF 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:

import (
"encoding/json""fmt""github.com/qri-io/jsonpointer"
)
vardocument= []byte(`{  "foo": { "bar": { "baz": [0,"hello!"] } }}`)
funcmain() {
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 documentgot, _:=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

About

golang implementation of IETF RFC6901: https://tools.ietf.org/html/rfc6901

Topics

Resources

Code of conduct

Security policy

Stars

16 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages