Blog

Alexander Bird Software • Blog

Learning to build useful, valuable software as part of a team.
About

jq cheat sheet

Notes on cool things to do with the JSON processor tool

(Link to official jq docs)

Making .jq files executable

  $ echo '"World"' | ./greeting.jq
  {
    "hello": "World"
  }
  $ cat greeting.jq
  #!/usr/bin/env jq -f
  
  {
    hello: .
  }

Table Formatting

Unix column formats tab separated output as a table and jq @tsv produces tab separated output.

  curl https://jsonplaceholder.typicode.com/users \
    | jq -r ".[] | [.id, .address.city, .name] | @tsv" \
    | column -ts $'\t'

Vim syntax highlighting

GitHub: vito-c/jq.vim


Written 2020-12