Thanks to visit codestin.com
Credit goes to pkg.go.dev

jsonpointer

package module
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2025 License: 0BSD Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrArrayIndexOutOfBounds = errors.New("jsonpointer: array index out of bounds")
	ErrInvalidArrayIndex     = errors.New("jsonpointer: invalid array index")
	ErrInvalidPointer        = errors.New("jsonpointer: invalid pointer")
	ErrValueNotFound         = errors.New("jsonpointer: value not found")
)

Functions

func Get

func Get(ptr string, value any) (any, error)

Get resolves the JSON pointer ptr against value and returns the result.

Types

type Pointer

type Pointer struct {
	// contains filtered or unexported fields
}

Pointer represents a parsed JSON pointer. Parsing a JSON pointer allows it to be evaluated multiple times more efficiently.

func MustParse

func MustParse(ptr string) Pointer

MustParse is like Parse but panics if the provided JSON pointer cannot be parsed, instead of returning an error.

func Parse

func Parse(ptr string) (Pointer, error)

Parse parses the JSON pointer ptr.

func (Pointer) AppendText added in v0.6.0

func (p Pointer) AppendText(buf []byte) ([]byte, error)

AppendText implements the encoding.TextAppender interface.

func (Pointer) Equal added in v0.3.0

func (p Pointer) Equal(o Pointer) bool

Equal compares two Pointers and reports whether they are equal.

func (Pointer) Get

func (p Pointer) Get(value any) (any, error)

Get resolves the JSON pointer parsed into p against value and returns the result.

func (Pointer) IsZero added in v0.5.0

func (p Pointer) IsZero() bool

IsZero reports whether the Pointer is the zero value. A zero Pointer value resolves against the root of a value.

func (Pointer) MarshalText added in v0.2.0

func (p Pointer) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (Pointer) NumTokens added in v0.7.0

func (p Pointer) NumTokens() int

NumTokens returns the number of reference tokens in the Pointer value.

func (Pointer) String added in v0.2.0

func (p Pointer) String() string

String returns a string representation of the Pointer value.

func (Pointer) Token added in v0.7.0

func (p Pointer) Token(i int) string

Token returns the reference token at the index i. Token returns an empty string if the requested index doesn't exist.

func (Pointer) Tokens added in v0.7.0

func (p Pointer) Tokens() []string

Tokens returns the reference tokens of the Pointer value.

func (Pointer) Trim added in v0.7.0

func (p Pointer) Trim(count int) Pointer

Trim removes the first count tokens from the Pointer value and returns the result.

func (*Pointer) UnmarshalText added in v0.2.0

func (p *Pointer) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL