jmespath.site
jmespath.site copied to clipboard
Flatten projections with data fields from parent object containing the list
{
"reservations": [
{
"instances": [
{"type": "small",
"state": {"name": "running"},
"tags": [{"Key": "Name",
"Values": ["Web"]},
{"Key": "version",
"Values": ["1"]}]},
{"type": "large",
"state": {"name": "stopped"},
"tags": [{"Key": "Name",
"Values": ["Web"]},
{"Key": "version",
"Values": ["1"]}]}
]
}, {
"instances": [
{"type": "medium",
"state": {"name": "terminated"},
"tags": [{"Key": "Name",
"Values": ["Web"]},
{"Key": "version",
"Values": ["1"]}]},
{"type": "xlarge",
"state": {"name": "running"},
"tags": [{"Key": "Name",
"Values": ["DB"]},
{"Key": "version",
"Values": ["1"]}]}
]
}
]
}
I wish to select all tags as a flat list from above data:
reservations[].instances[].tags[]
However, I wish to select the "state" information of each instance as a key inside each tag object too. Could you please tell me how to achieve this.