go-openapi/jsonpointer

GitHub: go-openapi/jsonpointer

Stars: 51 | Forks: 18

# jsonpointer [![Tests](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/8980d10d9c021800.svg)][test-url] [![Coverage](https://codecov.io/gh/go-openapi/jsonpointer/branch/master/graph/badge.svg)][cov-url] [![CI vuln scan](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/78d192ef81021801.svg)][vuln-scan-url] [![CodeQL](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/2ea5029eb7021802.svg)][codeql-url] [![Release](https://badge.fury.io/gh/go-openapi%2Fjsonpointer.svg)][release-url] [![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/jsonpointer)][gocard-url] [![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/go-openapi/jsonpointer)][codefactor-url] [![License](http://img.shields.io/badge/license-Apache%20v2-orange.svg)][license-url] [![GoDoc](https://pkg.go.dev/badge/github.com/go-openapi/jsonpointer)][godoc-url] [![Discord Channel](https://img.shields.io/discord/1446918742398341256?logo=discord&label=discord&color=blue)][discord-url] [![go version](https://img.shields.io/github/go-mod/go-version/go-openapi/jsonpointer)][goversion-url] ![Top language](https://img.shields.io/github/languages/top/go-openapi/jsonpointer) ![Commits since latest release](https://img.shields.io/github/commits-since/go-openapi/jsonpointer/latest) An implementation of JSON Pointer for golang, which supports go `struct`. ## Announcements ## Status API is stable and feature-complete. ## Import this library in your project go get github.com/go-openapi/jsonpointer ## Basic usage See also some [examples](./examples_test.go) ### 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 ## References also known as [RFC6901][RFC6901]. ## Licensing This library ships under the [SPDX-License-Identifier: Apache-2.0](./LICENSE). See the license [NOTICE](./NOTICE), which recalls the licensing terms of all the pieces of software on top of which it has been built. ## Limitations * [RFC6901][RFC6901] is now fully supported, including trailing "-" semantics for arrays (for `Set` operations). * Default behavior: JSON name detection in go `struct`s - Unlike go standard marshaling, untagged fields do not default to the go field name and are ignored. - anonymous fields are not traversed if untagged - the above limitations may be overcome by calling `UseGoNameProvider()` at initialization time. - alternatively, users may inject the desired custom behavior for naming fields as an option. ## Other documentation ## Cutting a new release Maintainers can cut a new release by either: * running [this workflow](https://github.com/go-openapi/jsonpointer/actions/workflows/bump-release.yml) * or pushing a semver tag * signed tags are preferred * The tag message is prepended to release notes
标签:EVTX分析