In this tutorial you’ll learn to use the jq JSON processor utility on the command line.
Handling data on the command line can be tricky and JSON data can be retrieved from an API however it will just come back as a long string! You can do anything with it other than store the whole thing in a file or variable. In JavaScript there is the JSON.parse() function which allows you to convert that JSON string in to a proper object which you can access the properties of to extract individual values. And that’s exactly the level of functionality that the jq JSON processor give you - JSON.parse() like functionality on the command line! In the tutorial you’ll learn how to send a request to an API and retrieve it’s JSON data directly on the command line. You’ll then learn how to pass this data to jq and how to extract individual properties of the JSON. We’ll finish up by covering how to store one such property in a variable - super useful if you want to just grab a specific bit of information from an API and use it in your scripts. There are some other important things you can do with jq such as iterating over each of the results and converting them to new values.