|
|
||
|---|---|---|
| .. | ||
| .cliff.toml | ||
| .editorconfig | ||
| .gitignore | ||
| .golangci.yml | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTORS.md | ||
| errors.go | ||
| LICENSE | ||
| NOTICE | ||
| pointer.go | ||
| README.md | ||
| SECURITY.md | ||
jsonpointer
An implementation of JSON Pointer for golang, which supports go struct.
Status
API is stable.
Import this library in your project
go get github.com/go-openapi/jsonpointer
Basic usage
See also some examples
Retrieving a value
import (
"github.com/go-openapi/jsonpointer"
)
var doc any
...
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.
}
...
Setting a value
...
var doc any
...
pointer, err := jsonpointer.New("/foo/1")
if err != nil {
... // error: e.g. invalid JSON pointer specification
}
doc, err = p.Set(doc, "value")
if err != nil {
... // error: e.g. key not found, index out of bounds, etc.
}
Change log
See https://github.com/go-openapi/jsonpointer/releases
References
https://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07
also known as RFC6901
Licensing
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.
Limitations
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.
Other documentation
Cutting a new release
Maintainers can cut a new release by either:
- running this workflow
- or pushing a semver tag
- signed tags are preferred
- The tag message is prepended to release notes