github.com/qri-io/jsonpointer
go get github.com/qri-io/jsonpointer

github.com/qri-io/jsonpointer

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

by qri-io

v0.1.1 (see all)License:MIT
go get github.com/qri-io/jsonpointer
Readme

Qri GoDoc License Codecov CI Go 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"
)

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

GitHub Stars

12

LAST COMMIT

2yrs ago

MAINTAINERS

0

CONTRIBUTORS

6

OPEN ISSUES

3

OPEN PRs

0
VersionTagPublished
v0.1.1
2yrs ago
v0.0.0-20180309164927-168dd9e45cf2
3yrs ago
v0.0.0-20190212172158-7f104febd1fd
3yrs ago
v0.1.0
3yrs ago
No alternatives found
No tutorials found
Add a tutorial