An implementation of JSON Pointer for golang, which supports go struct.
- 2025-12-19 : new community chat on discord
- a new discord community channel is available to be notified of changes and support users
- our venerable Slack channel remains open, and will be eventually discontinued on 2026-03-31
You may join the discord community by clicking the invite link on the discord badge (also above).
- 2026-04-15 : added support for trailing "-" for arrays
- this brings full support of RFC6901
- this is supported for types relying on the reflection-based implemented
- API semantics remain essentially unaltered. Exception:
Pointer.Set(document any,value any) (document any, err error)can only perform a best-effort to mutate the input document in place. In the case of adding elements to an array with a trailing "-", either pass a mutable array (*[]T) as the input document, or use the returned updated document instead. - types that implement the
JSONSetableinterface may not implement the mutation implied by the trailing "-"
API is stable.
go get github.com/go-openapi/jsonpointerSee also some examples
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.
}
... ...
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.
}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.
- RFC6901 is now fully supported, including trailing "-" semantics for arrays (for
Setoperations). - JSON name detection in go
structs- Unlike go standard marshaling, untagged fields do not default to the go field name and are ignored.
- anonymous fields are not traversed if untagged
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