# Json

cat README.md | jq .
cat README.md | jq '.[].id'
1
2

Get a single scalar values + (different form, as a pipeline)

cat s1.json | jq ' .spec.replicas '
cat s1.json | jq ' .spec | .replicas '
1
2

Get two scalar values

cat s1.json | jq ' .spec.replicas, .kind '
1

Get two scalar values and concatenate/format them into a single string

cat s1.json | jq ' "replicas: " + (.spec.replicas | tostring) + " kind: " + .kind '
1

Select an object from an array of object based on one of the names

cat dep.json | jq ' .status.conditions | map(select(.type == "Progressing")) '
1

# Extract, concatenate, select where key=value

Sourceopen in new window