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]
- Which, on the JSON:
{ "result" : 5 }
gives:
null
- And, on the JSON:
{ "result" : 6 }
gives:
{
"result": 6
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…