On the below simple JSON document
{ "result" : 5 }
I would like to filter or apply a condition in order to get value matching result > 5
On the below simple JSON document
{ "result" : 5 }
I would like to filter or apply a condition in order to get value matching result > 5
JMESPath is not really meant to act on a single object.
In order to achieve this, though, you can convert the object to an array, with the function to_array and back to an object, using | [0], in order to extract back the first element of the list, as explained in working with nested data.
All together, this gives the query:
to_array(@)[?result>`5`] | [0]
{ "result" : 5 }
gives:
null
{ "result" : 6 }
gives:
{
"result": 6
}