jq
jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text. [1]
jq can mangle the data format that you have into the one that you want with very little effort, and the program to do so is often shorter and simpler than you'd expect. [1]
- jq [EN] @ Fedora Package
- jq [EN] @ Homebrew Formula
Documentation
- Manual [EN]
Implementations
- jq play - A playground for jq [EN]
Syntax
jq [PARAMETER ...] FILTER [FILE ...]
Parameters
- -r, --raw-output
- With this parameter, if the filter's result is a string then it will be written directly to standard output rather than being formatted as a JSON string with quotes. This can be useful for making jq filters talk to non-JSON-based systems.
Examples
arp -a | jc --arp | jq 'del(.[].name, .[].permanent)'
Output:
[
{
"address": "10.0.0.1",
"hwtype": "ethernet",
"hwaddress": "0:0:5e:0:1:1",
"iface": "en9"
},
{
"address": "10.0.0.6",
"hwtype": "ethernet",
"hwaddress": "b8:69:f4:1:70:b1",
"iface": "en9"
}
]
References
- ↑ 1.0 1.1 Project contributors. "jq." jq project. https://stedolan.github.io/jq/ (accessed 06.05.2023)