An implementation of JSON Pointer for golang, which supports go struct.
API is stable.
go get github.com/go-openapi/jsonpointerSee examples
import (
"github.com/go-openapi/jsonpointer"
)
...
pointer, err := jsonpointer.New("/foo/1")
if err != nil {
... // error: e.g. invalid JSON pointer specification
}
value, kind, err := pointer.Get(doc)
if err != nil {
... // error: e.g. key not found, index out of bounds, etc.
}
...See https://github.com/go-openapi/jsonpointer/releases
https://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07
also known as RFC6901
This library ships under the SPDX-License-Identifier: Apache-2.0.
See the license NOTICE, which recalls the licensing terms of all the pieces of software on top of which it has been built.
The 4.Evaluation part of the previous reference, starting with 'If the currently referenced value is a JSON array, the reference token MUST contain either...' is not implemented.
That is because our implementation of the JSON pointer only supports explicit references to array elements: the provision in the spec to resolve non-existent members as "the last element in the array", using the special trailing character "-" is not implemented.