-- Leo's gemini proxy

-- Connecting to xoc3.io:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini;charset=UTF-8

back to xoc3.io


2021-08-04 - an intro to jq


i heard about the jq command sometime last year and i've had it installed for many months now, but i didn't need to use it until today.


jq on github


installation with pacman is straightforward:


sudo pacman -S jq

i'm guessing jq stands for "json query", but i couldn't find a source for that to know for sure. some nice things that i noticed immediately when i started using jq are:


syntax highlighting

pretty prints json (like `python -m json.tool`)

great documentation


one of the main reasons to use jq is for json filtering. Here are some simple examples:


json='{"a": {"b": ["c", "d", {"e": "f"}]}}'

echo $json | jq .         # prints: {"a": {"b": ["c", "d", {"e": "f"}]}}
echo $json | jq .a        # prints: {"b": ["c", "d", {"e": "f"}]}
echo $json | jq .a.b[0]   # prints: "c"
echo $json | jq .a.b[2].e # prints: "f"

-- Response ended

-- Page fetched on Fri May 10 21:32:33 2024