JMESPath is the representation of a compiled JMES path query. A JMESPath is
safe for concurrent use by multiple goroutines.
astASTNodeintr*treeInterpreter
Search evaluates a JMESPath expression against input data and returns the result.
func Compile(expression string) (*JMESPath, error)
func MustCompile(expression string) *JMESPath
Lexer contains information about the expression being tokenized.
// Internal buffer used for building up values.
// The current position in the string.
// The expression provided by the user.
// The width of the current rune. This
(*T) back()(*T) consumeLBracket() token(*T) consumeLiteral() (token, error)(*T) consumeNumber() token(*T) consumeQuotedIdentifier() (token, error)(*T) consumeRawStringLiteral() (token, error)(*T) consumeUnquotedIdentifier() token
Consume characters until the ending rune "r" is reached.
If the end of the expression is reached before seeing the
terminating rune "r", then an error is returned.
If no error occurs then the matching substring is returned.
The returned string will not include the ending rune.
Checks for a two char token, otherwise matches a single character
token. This is used whenever a two char token overlaps a single
char token, e.g. "||" -> tPipe, "|" -> tOr.
(*T) next() rune(*T) peek() rune(*T) syntaxError(msg string) SyntaxError
tokenize takes an expression and returns corresponding tokens.
func NewLexer() *Lexer
SyntaxError is the main error used whenever a lexing or parsing error occurs.
// Expression that generated a SyntaxError
// The location in the string where the error occurred
// Error message displayed to user
( T) Error() 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.
T : error
func (*Lexer).syntaxError(msg string) SyntaxError
func (*Parser).syntaxError(msg string) SyntaxError
func (*Parser).syntaxErrorToken(msg string, t token) SyntaxError
SliceParam refers to a single part of a slice.
A slice consists of a start, a stop, and a step, similar to
python slices.
NintSpecifiedbool
func computeSliceParams(length int, parts []sliceParam) ([]int, error)
func slice(slice []interface{}, parts []sliceParam) ([]interface{}, error)
Package-Level Functions (total 42, in which 5 are exported)
Compile parses a JMESPath expression and returns, if successful, a JMESPath
object that can be used to match against data.
MustCompile is like Compile but panics if the expression cannot be parsed.
It simplifies safe initialization of global variables holding compiled
JMESPaths.
NewLexer creates a new JMESPath lexer.
NewParser creates a new JMESPath parser.
Search evaluates a JMESPath expression against input data and returns the result.
IsFalse determines if an object is false based on the JMESPath spec.
JMESPath defines false values to be any of:
- An empty string array, or hash.
- The boolean value false.
- nil
ObjsEqual is a generic object equality check.
It will take two arbitrary objects and recursively determine
if they are equal.
Slice supports [start:stop:step] style slicing that's supported in JMESPath.
ToArrayNum converts an empty interface type to a slice of float64.
If any element in the array cannot be converted, then nil is returned
along with a second value of false.
ToArrayStr converts an empty interface type to a slice of strings.
If any element in the array cannot be converted, then nil is returned
along with a second value of false. If the input data could be entirely
converted, then the converted data, along with a second value of true,
will be returned.
Bit mask for [a-zA-Z_] shifted down 64 bits to fit in a single uint64.
When using this bitmask just be sure to shift the rune down 64 bits
before checking against identifierStartBits.
The pages are generated with Goldsv0.3.2-preview. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.