simon / jq

Last active 1 month ago

simon revised this gist 1 month ago · 3259735

1 file changed, 23 insertions

jq.md (file created)
@@ -0,0 +1,23 @@
1 + # jq
2 +
3 + * piping jq to less with colour:
4 +
5 + `jq -C . data.json |less -R`
6 +
7 +
8 + ---
9 +
10 + * piping streaming output to jq:
11 +
12 + `(echo 'asdf {"type":"stats"}'; sleep 1 ) | cut -f 2 -d ' ' | jq --unbuffered .`
13 +
14 +
15 + ---
16 +
17 + * loop over dict and get list of item keys which match a pattern:
18 +
19 + ```
20 + kubectl get secret secretname -n namespace -o json \
21 + | jq -r '.metadata.annotations | with_entries(select(.key|match("certmanager.k8s.io")))' \
22 + | jq -r '. | keys[]'
23 + ```