An implementation of JSON Pointer for golang, which supports go struct.
github.com/go-openapi/swag/jsonname is source directly here, so we no longer have any external dependencyjsonname was never really used by any other package, so it makes sense to deprecate it away from the swag family
and retrofit its functionality here. jsonpointer no longer get external dependencies, besides test dependencies.
2026-04-15 : added support for trailing "-" for arrays (v0.23.0)
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 JSONSetable interface may not implement the mutation implied by the trailing "-"
2026-04-15 : added support for optional alternate JSON name providers
API is stable and feature-complete.
The project continues to receive regular updates, bug fixes and hygiene maintenance (CI, linting, etc).
go get github.com/go-openapi/jsonpointer
See 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.
Set operations).structsUseGoNameProvider() at initialization time.Maintainers can cut a new release by either:
$ claude mcp add jsonpointer \
-- python -m otcore.mcp_server <graph>