Manual -r Ignore result format -f read filter from file |= Passes the values
Filter .items array, select & print id from file .json
jq -r --arg id "$id" '.items[] | select(.id == $id) | .id' file.json
Filter and transforrm
jq -r '{i: .id, t: .title}'
- .[] returns each element of the array returned in the response.
- [.org,.url] converts output to array
- @tsv (newer version) tab separator
.[] | {org: .agency, topic: .topic, url: .endpoint.url} | select(.topic == "CourtCaseEvent") | [.org,.url] | @tsv
- sort_by
sort_by(.topic) | .[] | {org: .agency, topic: .topic, url: .endpoint.url} | [.topic,.org,.url] | @csv
Without @csv using string interpolation ()
sort_by(.topic) | .[] | {org: .agency, topic: .topic, url: .endpoint.url} | "\(.topic)\t\(.org)\t\(.url)"
f
jq '.[] | {action: .category, id: .fileId, trackingId: .trackingId, time: .sentDateTime} | [.trackingId, .action, .category, .id, .time] | @csv' file.json