jmespath.site icon indicating copy to clipboard operation
jmespath.site copied to clipboard

Flatten projections with data fields from parent object containing the list

Open kidambisrinivas opened this issue 9 years ago • 0 comments

{
  "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.

kidambisrinivas avatar May 16 '16 23:05 kidambisrinivas