jpath

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: MIT Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPath      = errors.New("invalid path")
	ErrNotSlice         = errors.New("not a slice")
	ErrNotMap           = errors.New("not a map")
	ErrOutOfBounds      = errors.New("index out of bounds")
	ErrInvalidInterface = errors.New("cannot get interface of value")
	ErrNil              = errors.New("cannot get index or key of nil")
	ErrKeyType          = errors.New("cannot handle this type of key")
)

Functions

func EscapeKey

func EscapeKey(v interface{}) string

EscapeKey produces a string from a key (int, string, etc), enclosing it in quotes when necessary. This should be used when generating json paths to avoid ambiguity from keys such as `foo.bar`.

func ExecutePath

func ExecutePath(path string, i interface{}) (interface{}, error)

func HasSuffix

func HasSuffix(s, suffix string) bool

HasSuffix tests whether the string s ends with suffix, ignoring indices in brackets.

func Split

func Split(path string) (head, tail string)

func StripIndices

func StripIndices(path string) string

StripIndices removes the characters in between brackets in a json path

Types

This section is empty.

Jump to

Keyboard shortcuts

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