Added examples to JQ's notes

This commit is contained in:
Michele Cereda
2022-07-20 12:11:54 +02:00
parent 6265e9a2d2
commit 91e24b0019

View File

@@ -3,6 +3,12 @@
## TL;DR
```sh
# Only list keys.
jq 'keys' file.json
# Sort all the keys.
jq --sort-keys '.' input.json > output.json
# Add a key.
jq --arg REGION ${AWS_REGION} '.spec.template.spec.containers[]?.env? += [{name: "AWS_REGION", value: $REGION}]' /tmp/service.kube.json
@@ -27,9 +33,6 @@ jq '.extensionsGallery + {
itemUrl: "https://marketplace.visualstudio.com/items"
}' /usr/lib/code/product.json
# Sort all the keys.
jq --sort-keys '.' input.json > output.json
# Put specific keys on top.
jq '.objects = [(.objects[] as $in | {type,name,id} + $in)]' prod/dataPipeline_deviceLocationConversion_prod.json