-
-
Notifications
You must be signed in to change notification settings - Fork 23
Search Keywords
In addition to Search Expressions, YAML Path also provides some search keywords since version 3.5.0. Like programming language keywords, these are reserved words written in a specific notation form so as to avoid interference with other YAML Path expressions.
The general form of a keyword-based search is [KEYWORD(PARAMETERS)]
with optional white-space, where:
- The outermost
[]
pair is mandatory. -
KEYWORD
is one of the reserved Available Keywords. - The following
()
pair is mandatory, even when no parameters are passed. -
PARAMETERS
is a comma-delimited set of parameters passed to the search keyword's function. In documentation, optional parameters are denoted by using a[]
pair around parameters which can be omitted when not needed.
Some keywords support inversion, where nodes not matching the search are matched instead of those that do. Inversion is denoted by adding a !
prefix before the keyword itself, like [!KEYWORD(PARAMETERS)]
.
The available Search Keywords include:
-
has_child(NAME)
: Match nodes having a named, immediate child. This can be inverted. -
max(NAME)
: Match nodes having the highest value in the named child field. More than one node will be returned when they each have the same value. This can be inverted. -
min(NAME)
: Match nodes having the lowest value in the named child field. More than one node will be returned when they each have the same value. This can be inverted. -
name()
: Match only the name of the present key, discarding any child nodes. This cannot be inverted. -
parent([STEPS])
: Step up to the present node's immediate parent, or take multiple STEPS. This cannot be inverted.
If you'd like to see more search keyword capabilities added to YAML Path, please open a Feature Request Issue with the full description of the capability you seek. Note however that where YAML Path already supports the described capability through other means, such a request may be rejected after discussing this preceding capability unless it is agreed that the other means is onerous.