I have a json file that essentially looks like this:
{
"input": {
"user": "john",
"group": "johns_group"
},
"group_data": [
{
"name": "johns_group",
"members": ["john", "michael"]
},
{
"name": "sallys_group",
"members": ["sally", "jane"]
}
]
}
Is it possible for me to retrieve the group under group_data
with the name specified in input.group
using jmespath?
I've tried the following:
group_data[?contains(name, input.group)]
But it doesn't work. If I just put in the group name however:
group_data[?contains(name, 'johns_group')]
It does work. But I can't just hardcode the names because the group_data
, input.user
, and input.group
can all change.
If this isn't possible in pure jmespath with the way I've set it up, I have control over the structure of group_data
and can change it to be more jmespath friendly. My end goal is to be able to retrieve the group object and then return a bool if input.user
is in its members
list.