Documentation ¶
Index ¶
- Constants
- func DeepEqual(x, y interface{}) bool
- func RegisterFunction(name string, fn CustomFunction) error
- func Search(expression string, data interface{}) (interface{}, error)
- type ASTNode
- type CustomFunction
- type Executor
- type JMESPath
- type Lexer
- type Parser
- type SyntaxError
- type Value
- func (v *Value) Bool() (out bool)
- func (v *Value) CanSlice() bool
- func (v *Value) Contains(other *Value) bool
- func (v *Value) Float() (out float64)
- func (v *Value) Index(i int) *Value
- func (v *Value) Integer() (out int64)
- func (v *Value) Interface() interface{}
- func (v *Value) IsBool() bool
- func (v *Value) IsExpression() bool
- func (v *Value) IsFloat() bool
- func (v *Value) IsInteger() bool
- func (v *Value) IsNil() bool
- func (v *Value) IsNumber() bool
- func (v *Value) IsString() bool
- func (v *Value) Len() int
- func (v *Value) Reflect() reflect.Value
- func (v *Value) Slice(i, j int) *Value
- func (v *Value) String() (out string)
Constants ¶
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
Types ¶
type ASTNode ¶
type ASTNode struct {
// contains filtered or unexported fields
}
ASTNode represents the abstract syntax tree of a JMESPath expression.
func (ASTNode) PrettyPrint ¶
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.
type CustomFunction ¶
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 ¶
Compile parses a JMESPath expression and returns, if successful, a JMESPath object that can be used to match against data.
func MustCompile ¶
MustCompile is like Compile but panics if the expression cannot be parsed. It simplifies safe initialization of global variables holding compiled JMESPaths.
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer contains information about the expression being tokenized.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser holds state about the current expression being parsed.
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
}