JQ a lightweight command line processing tool for JSON
3 min readSep 12, 2023
I came across a CLI tool which felt worth a look.
JQ is a lightweight and flexible command-line processing tool which can be used for transforming JSON data to desired text format, can be used for filtering, restricting & extracting specific properties from the JSON.
How to install?
Using Brew
brew install jq
Using APT
apt install jq
Before we begin let say we have JSON file (employees.json) with contents in it
[
{
"id": 101,
"firstName": "Joan",
"lastName": "Paul",
"ctc": 60000
},
{
"id": 102,
"firstName": "Raj",
"lastName": "Singh",
"ctc": 65000
},
{
"id": 103,
"firstName": "Christy",
"lastName": "Franco",
"ctc": 75000
},
{
"id": 104,
"firstName": "Dean",
"lastName": "Backer",
"ctc": 55000
},
{
"id": 105,
"firstName": "Raj",
"lastName": "Dev",
"ctc": 72000
}
]
Here, is how you can use the JQ command can be used
jq '.' employees.json
or
cat employees.json | jq '.'