jq Flashcards
1
Q
jq (json processor): how to filter out deep level arrays and strings?
A
cat whatever.json | jq ‘.[] | select(.results[].confirmation.dealStatus==”REJECTED”)’
2
Q
jq (json processor): how to get the last item in array?
A
[-1]
version 1.5 and above
3
Q
jq: how to get unchanged output (identity operator)?
A
.
4
Q
jq: how to get item which has a special char in identifier?
A
cat ordercontainers.json | jq ‘.[-1] | .tim.”$date”’
5
Q
jq: how to get sub attribute from object?
A
cat whatever.json | jq ‘.[1] | .result’
6
Q
jq: how to merge to json files with objects into a single one?
A
jq -s ‘.[0] * .[1]’ file1 file2
7
Q
jq: how to merge to json files with arrays into a single one?
A
jq -s ‘.[0] + .[1]’ file1 file2