Quantcast
Channel: How to form correct JQ Expression to get exact output data from JSON file? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Inian for How to form correct JQ Expression to get exact output data from JSON file?

$
0
0

With a slight bit of reform, it could be written as below. The key is to reuse the variable $k once for forming the key name and then later to exclude it from the members.

.body.primarykey[] as $k | {   parameters: {($k): "" },   body: (.body.members | map(select(.name != $k) | {(.name): .type | ascii_downcase}) | add)}

jqplay - https://jqplay.org/s/hdTpOhvZ0I2


Viewing all articles
Browse latest Browse all 2

Trending Articles