Listen to this Post

The `jq` command is a powerful tool for parsing, filtering, and manipulating JSON data in Linux (and other OS). If you work with APIs, web scraping, or JSON logs, mastering `jq` can save you time and frustration.
Basic JSON Beautification
Ugly JSON (single-line):
[{"results":[{"data":{"billingAccountsQuery":{"checkBillingAccountReopenable":{"status":"ACCOUNT_NOT_CLOSED"}}},"path":[]}],"responseContext":{"eti":"AZ<snip>NC8="}}]
Use `jq` to format it:
curl "https://host.with.json.com/json" | jq
Output (formatted & colorized):
[
{
"results": [
{
"data": {
"billingAccountsQuery": {
"checkBillingAccountReopenable": {
"status": "ACCOUNT_NOT_CLOSED"
}
}
},
"path": []
}
],
"responseContext": {
"eti": "AZSnT/P5r<snip>SE="
}
}
]
You Should Know: Advanced jq Filtering
1. Exclude Entries Containing “text/html”
curl "https://host.with.json.com/json" | jq '[.[] | select(all(. != "text/html"))]'
– `.[]` iterates over each sub-array.
– `select(all(. != “text/html”))` keeps only sub-arrays without “text/html”.
2. Extract Specific Fields
curl "https://api.example.com/data" | jq '.results[].data.billingAccountsQuery'
3. Filter by Key Value
echo '{"users":[{"name":"Alice","role":"admin"},{"name":"Bob","role":"user"}]}' | jq '.users[] | select(.role == "admin")'
4. Keep Color Output in Paginated View
curl "https://host.with.json.com/json" | jq -C . | less -R
Pro Tip: Create an alias for color-preserved pagination:
alias jQQ='jq -C . | less -R'
Now use:
curl "https://json.host" | jQQ
What Undercode Say
`jq` is essential for cybersecurity analysts, DevOps engineers, and developers working with JSON data. Key takeaways:
– Always format JSON for readability (jq .).
– Filter data precisely (select, map, del).
– Combine with curl, grep, and `awk` for powerful parsing.
Bonus Commands
- Extract Nested Values:
jq '.responseContext.eti' file.json
- Modify JSON:
jq '.results[bash].data.billingAccountsQuery.status = "CLOSED"' file.json
- Convert JSON to CSV:
jq -r '.users[] | [.name, .role] | @csv' data.json
Expected Output:
{
"status": "ACCOUNT_NOT_CLOSED",
"filtered_data": "clean output"
}
Prediction
As APIs dominate modern applications, `jq` will remain a critical tool for parsing and automation in cybersecurity and IT workflows. Expect more integrations with AI-driven log analysis.
URLs (if needed):
References:
Reported By: Activity 7328336775792242688 – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅


