Well it looks to me like you are having multiple typos and then one big issue in you JMESPath expression.
First things first, for your JSON to be totally valid:
- You should use double quotes, not single ones
- Your names should be inclosed in double quotes too
Source: https://restfulapi.net/json-syntax/
So, here is your correct JSON data:
{
"Item": [
{
"key1": "one",
"key2": "two",
"key3": [
"Sam",
"Jack"
]
},
{
"key1": "one",
"key2": "two",
"key3": [
"Annie",
"Jason"
]
}
]
}
Then, in your JMESPath you have two typos:
- Your top level name is
Item not Items
- The correct JMESPath expression is
contains and not contain
And finally, but maybe the most important issue your contains expression is incorrect, it tests the return of contains against the string 'true' when contains does return a boolean true or false.
Because of this, you have to compare the return of contains against the raw string literal `true`.
So your correct query ends up being:
Item[].key3[?contains(@, `Annie`) == `true`]
Which gives:
[
[],
[
"Annie"
]
]