jsonpath

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultJSONPathParser = NewJSONPathParser()

Functions

func RelaxedJSONPathExpression

func RelaxedJSONPathExpression(pathExpression string) (string, error)

copied from kubectl

Types

type JSONPathFields

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

JSONPathFields is a struct that holds a JSONPathParser instance and the data to be queried by JSONPath expressions.

func NewJSONPathFields

func NewJSONPathFields(jpParser *JSONPathParser, data interface{}) *JSONPathFields

NewJSONPathFields creates and returns a new instance of JSONPathFields with the given parser and data.

func (JSONPathFields) Get

func (fs JSONPathFields) Get(fieldPath string) (value string)

Get retrieves the value at the specified JSONPath expression from the data and returns it as a string.

func (JSONPathFields) Has

func (fs JSONPathFields) Has(fieldPath string) (exists bool)

Has checks if the given JSONPath expression exists in the data, returning a boolean indicating its existence.

type JSONPathParser

type JSONPathParser struct {
	sync.Mutex
	// contains filtered or unexported fields
}

JSONPathParser is a struct that holds a cache of parsed JSONPath expressions for efficient reuse.

func NewJSONPathParser

func NewJSONPathParser() *JSONPathParser

NewJSONPathParser creates and returns a new instance of JSONPathParser with an empty cache.

func (*JSONPathParser) Parse

func (j *JSONPathParser) Parse(path string) (*jsonpath.JSONPath, error)

Parse takes a JSONPath expression string and returns a parsed JSONPath object or an error if the expression is invalid.

Jump to

Keyboard shortcuts

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