Documentation ¶
Index ¶
- func NewInterpreter() *treeInterpreter
- func Search(expression string, data interface{}, opts ...InterpreterOption) (interface{}, error)
- type ASTNode
- type ASTNodeType
- type ArgSpec
- type FunctionCaller
- type FunctionEntry
- type Interpreter
- type InterpreterOption
- type JMESPath
- type JpFunction
- type JpType
- type Lexer
- type NotFoundError
- type Parser
- type SyntaxError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewInterpreter ¶
func NewInterpreter() *treeInterpreter
func Search ¶
func Search(expression string, data interface{}, opts ...InterpreterOption) (interface{}, error)
Search evaluates a JMESPath expression against input data and returns the result.
Types ¶
type ASTNode ¶
type ASTNode struct { NodeType ASTNodeType Value interface{} Children []ASTNode }
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 ASTNodeType ¶
type ASTNodeType int
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 )
func (ASTNodeType) String ¶
func (i ASTNodeType) String() string
type FunctionCaller ¶
type FunctionCaller struct {
// contains filtered or unexported fields
}
var DefaultFunctionCaller *FunctionCaller = NewFunctionCaller()
func NewFunctionCaller ¶
func NewFunctionCaller() *FunctionCaller
func (*FunctionCaller) CallFunction ¶
func (f *FunctionCaller) CallFunction(name string, arguments []interface{}, intr *treeInterpreter) (interface{}, error)
func (*FunctionCaller) Register ¶
func (f *FunctionCaller) Register(e FunctionEntry)
type FunctionEntry ¶
type FunctionEntry struct { Name string Arguments []ArgSpec Handler JpFunction HasExpRef bool }
type Interpreter ¶
type Interpreter interface { // Interpret the node and return results Execute(node ASTNode, value interface{}, opts ...InterpreterOption) (interface{}, error) }
type InterpreterOption ¶
type InterpreterOption func(interpreterOptions) interpreterOptions
func WithFunctionCaller ¶
func WithFunctionCaller(functionCaller *FunctionCaller) InterpreterOption
type JMESPath ¶
type JMESPath struct {
// contains filtered or unexported fields
}
JMESPath is the representation 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.
func (*JMESPath) Search ¶
func (jp *JMESPath) Search(data interface{}, opts ...InterpreterOption) (interface{}, error)
Search evaluates a JMESPath expression against input data and returns the result.
type JpFunction ¶
type JpFunction func(arguments []interface{}) (interface{}, error)
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer contains information about the expression being tokenized.
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
NotFoundError is returned when it is impossible to resolve the AstField
func (NotFoundError) Error ¶
func (n NotFoundError) Error() string
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.