jmespath

package module
v0.0.0-...-00188b1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

README

go-jmespath - A JMESPath implementation in Go

Build Status

See http://jmespath.org for more info.

Documentation

Index

Constants

View Source
const (
	ASTEmpty astNodeType = iota
	ASTComparator
	ASTCurrentNode
	ASTExpRef
	ASTFunctionExpression
	ASTField
	ASTFilterProjection
	ASTFlatten
	ASTIdentity
	ASTIndex
	ASTIndexExpression
	ASTKeyValPair
	ASTLiteral
	ASTMultiSelectHash
	ASTMultiSelectList
	ASTOrExpression
	ASTAndExpression
	ASTNotExpression
	ASTPipe
	ASTProjection
	ASTSubexpression
	ASTSlice
	ASTValueProjection
	ASTRootNode
	ASTKeyValExprPair
)

Variables

This section is empty.

Functions

func DeepEqual

func DeepEqual(x, y interface{}) bool

DeepEqual reports whether x and y are “deeply equal,” defined as follows. Two values of identical type are deeply equal if one of the following cases applies. Values of distinct types are never deeply equal.

Array values are deeply equal when their corresponding elements are deeply equal.

Struct values are deeply equal if their corresponding fields, both exported and unexported, are deeply equal.

Func values are deeply equal if both are nil; otherwise they are not deeply equal.

Interface values are deeply equal if they hold deeply equal concrete values.

Map values are deeply equal when all of the following are true: they are both nil or both non-nil, they have the same length, and either they are the same map object or their corresponding keys (matched using Go equality) map to deeply equal values.

Pointer values are deeply equal if they are equal using Go's == operator or if they point to deeply equal values.

Slice values are deeply equal when all of the following are true: they are both nil or both non-nil, they have the same length, and either they point to the same initial entry of the same underlying array (that is, &x[0] == &y[0]) or their corresponding elements (up to length) are deeply equal. Note that a non-nil empty slice and a nil slice (for example, []byte{} and []byte(nil)) are not deeply equal.

Other values - numbers, bools, strings, and channels - are deeply equal if they are equal using Go's == operator.

In general DeepEqual is a recursive relaxation of Go's == operator. However, this idea is impossible to implement without some inconsistency. Specifically, it is possible for a value to be unequal to itself, either because it is of func type (uncomparable in general) or because it is a floating-point NaN value (not equal to itself in floating-point comparison), or because it is an array, struct, or interface containing such a value. On the other hand, pointer values are always equal to themselves, even if they point at or contain such problematic values, because they compare equal using Go's == operator, and that is a sufficient condition to be deeply equal, regardless of content. DeepEqual has been defined so that the same short-cut applies to slices and maps: if x and y are the same slice or the same map, they are deeply equal regardless of content.

func RegisterFunction

func RegisterFunction(name string, fn CustomFunction) error
func Search(expression string, data interface{}) (interface{}, error)

Search evaluates a JMESPath expression against input data and returns the result.

Types

type ASTNode

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

ASTNode represents the abstract syntax tree of a JMESPath expression.

func (ASTNode) PrettyPrint

func (node ASTNode) PrettyPrint(indent int) string

PrettyPrint will pretty print the parsed AST. The AST is an implementation detail and this pretty print function is provided as a convenience method to help with debugging. You should not rely on its output as the internal structure of the AST may change at any time.

func (ASTNode) String

func (node ASTNode) String() string

type CustomFunction

type CustomFunction func(input []Value, executor *Executor) (interface{}, error)

type Executor

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

func (*Executor) Execute

func (ex *Executor) Execute(expr Value, item interface{}) (interface{}, error)

type JMESPath

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

JmesPath is the epresentation of a compiled JMES path query. A JmesPath is safe for concurrent use by multiple goroutines.

func Compile

func Compile(expression string) (*JMESPath, error)

Compile parses a JMESPath expression and returns, if successful, a JMESPath object that can be used to match against data.

func MustCompile

func MustCompile(expression string) *JMESPath

MustCompile is like Compile but panics if the expression cannot be parsed. It simplifies safe initialization of global variables holding compiled JMESPaths.

func (*JMESPath) Search

func (jp *JMESPath) Search(data interface{}) (interface{}, error)

Search evaluates a JMESPath expression against input data and returns the result.

type Lexer

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

Lexer contains information about the expression being tokenized.

func NewLexer

func NewLexer() *Lexer

NewLexer creates a new JMESPath lexer.

type Parser

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

Parser holds state about the current expression being parsed.

func NewParser

func NewParser() *Parser

NewParser creates a new JMESPath parser.

func (*Parser) Parse

func (p *Parser) Parse(expression string) (ASTNode, error)

Parse will compile a JMESPath expression.

type SyntaxError

type SyntaxError struct {
	Expression string // Expression that generated a SyntaxError
	Offset     int    // The location in the string where the error occurred
	// contains filtered or unexported fields
}

SyntaxError is the main error used whenever a lexing or parsing error occurs.

func (SyntaxError) Error

func (e SyntaxError) Error() string

func (SyntaxError) HighlightLocation

func (e SyntaxError) HighlightLocation() string

HighlightLocation will show where the syntax error occurred. It will place a "^" character on a line below the expression at the point where the syntax error occurred.

type Value

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

func AsValue

func AsValue(inp interface{}) *Value

func (*Value) Bool

func (v *Value) Bool() (out bool)

func (*Value) CanSlice

func (v *Value) CanSlice() bool

func (*Value) Contains

func (v *Value) Contains(other *Value) bool

func (*Value) Float

func (v *Value) Float() (out float64)

func (*Value) Index

func (v *Value) Index(i int) *Value

func (*Value) Integer

func (v *Value) Integer() (out int64)

func (*Value) Interface

func (v *Value) Interface() interface{}

func (*Value) IsBool

func (v *Value) IsBool() bool

func (*Value) IsExpression

func (v *Value) IsExpression() bool

func (*Value) IsFloat

func (v *Value) IsFloat() bool

func (*Value) IsInteger

func (v *Value) IsInteger() bool

func (*Value) IsNil

func (v *Value) IsNil() bool

func (*Value) IsNumber

func (v *Value) IsNumber() bool

func (*Value) IsString

func (v *Value) IsString() bool

func (*Value) Len

func (v *Value) Len() int

func (*Value) Reflect

func (v *Value) Reflect() reflect.Value

func (*Value) Slice

func (v *Value) Slice(i, j int) *Value

func (*Value) String

func (v *Value) String() (out string)

Directories

Path Synopsis
cmd
jpgo
Basic command line interface for debug and testing purposes.
Basic command line interface for debug and testing purposes.

Jump to

Keyboard shortcuts

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