All tags
json
Narrow down
Other tips16
- Tip
jq -r '.files[] | @sh' data.jsonjq @sh quotes values so the shell can use them safelyTurns JSON strings into single-quoted shell words that survive spaces and apostrophes.2 Dec 2026 - Tip
jq -n -c '$ARGS.positional' --args a "b c"jq --args puts extra command line words into $ARGS.positionalPasses any number of values from the shell to a jq filter as an array.2 Dec 2026 - Tip
echo '{"id":1,"payload":"{\"user\":\"ann\",\"tags\":[\"x\",\"y\"]}"}' | jq -c '.payload | fromjson | .tags'Jq fromjson opens JSON that was stored inside a stringParses a string field that itself contains JSON, so you can filter into it.2 Dec 2026 - Tip
jq 'with_entries(.key |= ascii_upcase)'jq with_entries renames or drops object keys in one filterRuns a filter on every key and value of a JSON object to rename or drop keys.2 Dec 2026 - Tip
jq empty config.jsonOne empty filter checks that a JSON file parsesCatch a broken config before the program that reads it does.1 Dec 2026 - TipPaths() tells you where in a big JSON document a value livesFind the exact route to a value without scrolling through nested output.1 Dec 2026
- Tip
jq -c --slurpfile u users.json 'Slurpfile joins two JSON files on a shared idAdd names from one export to records in another without writing a program.1 Dec 2026 - Tip
jq '.replicas |= . + 1' deploy.jsonjq |= changes one value and keeps the rest of the documentEdit a field in place, using its current value, without rebuilding the document.30 Nov 2026 - Tip
cut -d: -f1,7 /etc/passwd | jq -R 'split(":") | {user: .[0], shell: .[1]}'Jq -R reads plain text lines, so jq can build records from themTurn ordinary text lines into strings jq can split, filter and wrap.30 Nov 2026 - Tip
jq -r '.[] | "\(.name): \(.description // "no description")"' repos.jsonJq's // operator fills in a default when a field is missingReplace missing or null fields with a fallback value in jq output.30 Nov 2026 - Tip
diff <(jq -S . old.json) <(jq -S . new.json)Jq -S sorts keys, so diff shows what really changed between two filesCompare two JSON files without noise from key order or formatting.30 Nov 2026 - Tip
cat defaults.jsonJq '. * input' merges a config file with an override fileDeep merge two config files so the second one overrides only what it sets.30 Nov 2026 - Tip
jq -c '.[]' hosts.jsonjq -c prints each JSON result on a single linePrints every jq result as one compact line, ready for loops and line-based tools.27 Nov 2026 - Tip
jq -s 'length' events.jsonljq -s reads all the JSON input into one array so you can count or sum itCollects every JSON value from the input into one array, so you can count, sum or merge them.27 Nov 2026 - Tip
NAME="web 1"Jq --arg passes a variable from your script into a jq filter without quoting troubleHands shell variables to jq safely, as strings or as real JSON values.26 Nov 2026 - Tip
echo '{"name":"nextdash"}' | jq -r '.name'Jq -r prints strings without the quotesPrints JSON strings as plain text, so jq output works in scripts and loops.19 Nov 2026
Shell4
- Tip
sudo smartctl -a --json /dev/sda | jq '.smart_status.passed'Smartctl --json turns disk health into data a script can readPrints SMART data as JSON, so scripts can check pass or fail, temperature and hours with jq.3 Dec 2026 - Tip
journalctl -t demoapp -n 1 -o json-seq | od -c | head -1journalctl -o json-seq writes records that survive a cut off streamGet JSON records with a clear start marker, so a half written line can be skipped.30 Nov 2026 - Tip
echo "$TOKEN" | jq -R 'split(".")[1] | gsub("-";"+") | gsub("_";"/") | @base64d | fromjson'Jq @base64d reads the payload of a JWT in the terminalDecode the middle part of a JWT to see its claims and expiry time.30 Nov 2026 - Tip
journalctl -o json --output-fields=MESSAGE,PRIORITY -n 3journalctl --output-fields keeps JSON output to the fields you nameLimits JSON or verbose output to the fields you list, which keeps scripts small and fast.26 Nov 2026
Docker3
- Tip
jq -c 'sort_by(-.mem) | .[:2] | map(.name)' containers.jsonjq sort_by with a slice gives you the top 5 of anythingSort records on a field and keep only the first few.30 Nov 2026 - Tip
jq -r '.[] | [.name, .mem] | @tsv' containers.json | sort -t$'\t' -k2 -n | column -tjq @tsv turns API output into columns for cut, sort and awkFlatten records into tab separated lines that classic text tools can handle.30 Nov 2026 - Tip
jq -c 'group_by(.state) | map({state: .[0].state, count: length})' containers.jsonjq group_by counts records per value, like GROUP BY in SQLCount how many records share a value, straight from an API response.30 Nov 2026
Media2
- Tip
jq -n -c 'limit(3; range(1; 1000000000))'jq limit(n; stream) stops after n results instead of reading everythingTakes only the first few results of a jq generator and quits early.2 Dec 2026 - Tip
jq -cn --stream 'fromstream(1|truncate_stream(inputs))' big.jsonStream mode reads a huge JSON array without loading it all at onceProcess a file that is too big for a normal jq run.1 Dec 2026
Python2
- Tip
import jsonPython's json.dumps(default=str) stops the not serializable errorWrite dates, decimals and paths to a file without a custom encoder class.30 Nov 2026 - Tip
curl -s https://example.com/api | python3 -m json.toolpython3 -m json.tool makes ugly JSON readable in one pipeTakes messy one-line JSON and prints it indented, so you can read it and spot typos.1 Nov 2026
Network2
- Tip
if curl -fsS https://example.com/health | jq -e '.status == "ok"' >/dev/null; thenJq -e sets the exit code, so a shell if can test a valueUse a jq check directly in an if statement or a health check script.30 Nov 2026 - Tip
curl -s -o /dev/null -w '%{json}' https://example.com/ | jq .curl -w %{json} dumps every transfer detail as one JSON objectGet all write-out values at once and pick fields with jq.30 Nov 2026
Web1
Security1
AI1
Nothing matches.