jsonpointer

package
v0.0.0-...-cdf09a4 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package jsonpointer contains RFC 6901 JSON Pointer implementation.

Index

Constants

View Source
const DefaultDepthLimit = 1000

DefaultDepthLimit is default depth limit for ResolveCtx.

Variables

This section is empty.

Functions

func DummyURL

func DummyURL() *url.URL

DummyURL is dummy URL for testing purposes.

func Resolve

func Resolve(ptr string, node *yaml.Node) (*yaml.Node, error)

Resolve takes given pointer and returns byte slice of requested value if any. If value not found, returns NotFoundError.

Types

type NotFoundError

type NotFoundError struct {
	Pointer string
}

NotFoundError reports that requested value is not found.

func (*NotFoundError) Error

func (n *NotFoundError) Error() string

Error implements error.

type RefKey

type RefKey struct {
	// Loc is an URL of JSON document.
	Loc string
	// Ptr is JSON Pointer.
	Ptr string
}

RefKey is JSON Reference key.

func (*RefKey) FromURL

func (r *RefKey) FromURL(u *url.URL)

FromURL sets RefKey from URL.

func (RefKey) IsZero

func (r RefKey) IsZero() bool

IsZero returns true if RefKey is zero.

func (RefKey) String

func (r RefKey) String() string

String returns string representation of reference.

type ResolveCtx

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

ResolveCtx is JSON Reference resolve context.

func NewResolveCtx

func NewResolveCtx(root *url.URL, depthLimit int) *ResolveCtx

NewResolveCtx creates new ResolveCtx.

func (*ResolveCtx) AddKey

func (r *ResolveCtx) AddKey(key RefKey, file location.File) error

AddKey adds reference key to context.

func (*ResolveCtx) Delete

func (r *ResolveCtx) Delete(key RefKey)

Delete removes reference from context.

func (*ResolveCtx) File

func (r *ResolveCtx) File() (f location.File)

File returns last file from stack.

func (*ResolveCtx) IsRoot

func (r *ResolveCtx) IsRoot(key RefKey) bool

IsRoot returns true if location stack is empty.

func (*ResolveCtx) Key

func (r *ResolveCtx) Key(ref string) (key RefKey, _ error)

Key creates new reference key.

Jump to

Keyboard shortcuts

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