-
Notifications
You must be signed in to change notification settings - Fork 1
/
jq.txt
33 lines (23 loc) · 893 Bytes
/
jq.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Use identity to get a pretty output:
curl ... | jq .
Arrays: []
* .[] - get all
* .[0]
.foo | .[] is the same as .foo[]
Objects: {}
* .foo.bar <=> .foo | .bar
\
+-- filter (data IN, data OUT)
Responses can be constructed like so:
{ "site": .Name, "IP": .Value }
.foo, .bar
\
+-- concatenate both value streams
+-- surround with []s and use -r to get on the same line
Examples:
% jq -r '.solutions|.[]|select(.lang=="perl"and.scoring=="bytes")|"# "+.hole,.code+"\n"' code-golf-export.json
% aws route53 list-resource-record-sets --hosted-zone-id ... |
jq -r '.ResourceRecordSets | .[] | if .Type == "A" then [.Name, (.ResourceRecords | .[] | .Value)] else empty end | @tsv'
jq -r '.. | .ResourceRecords? | .[]? | .Value'
\ \
+-- like // in xpath +-- ignore errors