get_jmespath¶
Description¶
Process an object or array expression using a query written in the JMESPath query language. This function provides advanced functionality to extract, filter, and manipulate object or array data. Below we provide a few basic examples of how to use the JMESPath query language. See the JMESPath Tutorial in the JMESPath documentation for more information.
Note: for use cases that do not require the advanced features of JMESPath, see get_field and get_item.
Return type¶
variant
Domain¶
This is a scalar function (calculates a single output value for a single input row.)
Categories¶
Usage¶
get_jmespath(value, query)
Argument |
Type |
Optional |
Repeatable |
Restrictions |
---|---|---|---|---|
value |
storable |
no |
no |
none |
query |
string |
no |
no |
constant |
Examples¶
make_col value:get_jmespath(arr, "[*].value")
Flatten an array of objects by selecting the specific key “value” out of the
objects, creating a new array for the results. For example, given input
[{"key":"a", "value":"b"}, {"key":"c", "value":"d"}]
, this get_jmespath()
expression returns ["b", "d"]
.
make_col value:get_jmespath(arr, "[?state=='running'].name")
Filter an array of objects and return the name
of the objects whose field
state
has value "running"
. For example, the following input returns ["app2", "app3"]
:
[
{
"name": "app1",
"state": "idle"
},
{
"name": "app2",
"state": "running"
},
{
"name": "app3",
"state": "running"
}
]