Babak K. Shandiz
Babak K. Shandiz's Blog

Babak K. Shandiz's Blog

Living in the Shell #4; jq (JSON)

Living in the Shell #4; jq (JSON)

Babak K. Shandiz's photo
Babak K. Shandiz
ยทNov 27, 2021ยท

1 min read

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
ย 
Share this