jq

noun

say it: “JAY-KYOO” /ˈdʒeɪˈkju/

A command-line tool that reads JSON data and picks out the parts you ask for.

What is jq?

jq reads JSON, the labeled data web APIs answer with. Its filter follows the labels in with dots, [] goes through every item in a list, select( ) keeps the items whose test is true, and -r prints text without quotes, ready for a bash loop.

jq -r '.properties.periods[] | select(.probabilityOfPrecipitation.value >= 50) | .name' forecast.json
# Thursday Night
# Friday
# Friday Night

In a sentence

  • “With -r, jq prints plain lines a while read loop can use.”
  • “jq picked out the three rainy periods from the saved forecast.”

Level: Journeyman · More Unix terms at this level

Updated