jmespath / jmespath/jmespath.site

More examples on Concatenating nested elements

Open
#80 1 comment 6 reactions 0 assignees View on GitHub
Dominant language
Makefile
Stars
61
Forks
61
PR merge metrics
No merged PRs in 30d

Description

Hi,

I think it would be very nice to add an example on how to use a join to concatenate the values of two keys inside a nested list of key values.

Using the query syntax I tried to create tuples combining the values of name and value(see below json structure) but it took me a lot of time to figure that out as there was no specific example on the Jmespath official web doc (the online jmspath validators didn't help neither in my case) .

Anyway, in order to get that I had to run the below

```
[*].capabilities[].join(':',[name,value])

```

below is the json source input
```
[
{
"apiVersions": null,
"capabilities": [
{
"name": "MaxResourceVolumeMB",
"value": "10240"
},
{
"name": "OSVhdSizeMB",
"value": "1047552"
},
{
"name": "vCPUs",
"value": "1"
},
{
"name": "HyperVGenerations",
"value": "V1"
},
{
"name": "MemoryGB",
"value": "2"
},
{
"name": "MaxNetworkInterfaces",
"value": "2"
}
],
"capacity": null,
"costs": null,
"family": "standardAv2Family",
"kind": null,
"locationInfo": [
{
"location": "eastus",
"zoneDetails": [],
"zones": [
"3",
"2",
"1"
]
}
],
"locations": [
"eastus"
],
"name": "Standard_A1_v2",
"resourceType": "virtualMachines",
"restrictions": [],
"size": "A1_v2",
"tier": "Standard"
},
..
}
]
```

the result will look like below :

```
[
"MaxResourceVolumeMB:10240",
"OSVhdSizeMB:1047552",
"vCPUs:1",
"HyperVGenerations:V1",
"MemoryGB:2",
"MaxNetworkInterfaces:2"
]

```

thanks

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.