Living in the Shell #4; jq (JSON)
Babak K. Shandiz
Posted on November 26, 2021
jq
π§Ή
JSON formatter/prettifier.
π https://stedolan.github.io/jq/
π https://github.com/stedolan/jq
Installation (on Debian)
sudo apt-get install jq
Format/prettify
echo -n '{"who":["me","you"],"when":"now"}' | jq
{ "who": [ "me", "you" ], "when": "now" }
Indentation with tab --tab
echo -n '{"who":["me","you"],"when":"now"}' | jq --tab
Compact -c
cat << EOF | jq -c
{
"who": [
"me",
"you"
],
"when": "now"
}
EOF
{"who":["me","you"],"when":"now"}
Sort keys -S
echo -n '{"z":"z","a":"a"}' | jq -S
{ "a": "a", "z": "z" }
Uncolorize output (monochrome) -M
echo -n '{"who":"me","when":"now"}' | jq -M
π πͺ π
π©
Babak K. Shandiz
Posted on November 26, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.