Krikri::JMESPath
A JMESPath query engine backing the json_query filter (real
Ansible's own filter from community.general, commonly reachable as
a bare name). Implemented here rather than vendored: the Crystal
ecosystem has no maintained JMESPath shard, so this is a from-scratch
recursive-descent parser + evaluator over JSON::Any.
Supported grammar (per the JMESPath specification):
- field access (
foo,foo.bar, quoted"a-b") - the current node
@and JSON literals in backticks (`42`) - index
[0](negative ok) and slices[1:10:2] - wildcards
[*]/.*, list flattening[], filters[?expr] - multi-select lists
[a, b]and hashes{k: v} - pipe
|, and/or/not (&&,||,!), comparisons (==,!=,<,<=,>,>=) - expression references
&exprfor the by/map functions - functions: length, keys, values, type, not_null, to_string, to_number, to_array, abs, ceil, floor, avg, sum, min, max, min_by, max_by, sort, sort_by, reverse, join, contains, starts_with, ends_with, map, merge
Projection semantics follow the spec's observable behavior: a
wildcard/flatten/filter produces a projection, and a field access /
index / slice applied to a projection maps over its elements, dropping
null results. Syntactically invalid expressions raise
JMESPath::Error (real Ansible's json_query fails the task on an
unparseable expression too).
Constants
NULL = JSON::Any.new(nil)
Class methods
Nested types
- Krikri::JMESPath::AndOp
- Krikri::JMESPath::Comparison
- Krikri::JMESPath::Current
- Krikri::JMESPath::Error
- Krikri::JMESPath::Evaluator
- Krikri::JMESPath::ExpRef
- Krikri::JMESPath::Field
- Krikri::JMESPath::Filter
- Krikri::JMESPath::Flatten
- Krikri::JMESPath::FunctionCall
- Krikri::JMESPath::Index
- Krikri::JMESPath::Literal
- Krikri::JMESPath::MultiSelectHash
- Krikri::JMESPath::MultiSelectList
- Krikri::JMESPath::Node
- Krikri::JMESPath::NotOp
- Krikri::JMESPath::OrOp
- Krikri::JMESPath::Parser
- Krikri::JMESPath::Pipe
- Krikri::JMESPath::Slice
- Krikri::JMESPath::SubExpression
- Krikri::JMESPath::Token
- Krikri::JMESPath::TokenKind
- Krikri::JMESPath::Tokenizer
- Krikri::JMESPath::Wildcard