_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN
Let's talk

jq — zpracování JSON na příkazové řádce

07. 08. 2025 1 min read intermediate

JSON je všude — API, konfigurace, logy. jq je jako sed/awk pro JSON — filtruje a transformuje data přímo z terminálu.

Basics

sudo apt install jq echo ‘{“name”:”test”,”value”:42}’ | jq ‘.’

Filtrování

curl -s api/data | jq ‘.results[0].name’ jq ‘.[] | .email’ users.json jq ‘.[] | select(.age > 30)’ users.json jq ‘.[] | {name: .name, email: .email}’ users.json

Transformace

jq ‘{hostname: .name, cores: .cpu}’ server.json jq -r ‘.[] | [.name, .email] | @csv’ users.json jq -s ‘.[0] * .[1]’ defaults.json overrides.json

Agregace

jq ‘.users | length’ data.json jq ‘[.[] | .price] | {min: min, max: max, avg: (add / length)}’ products.json jq ‘[.[] | .category] | unique’ products.json

Exampley

curl -s ‘https://api.github.com/users/torvalds/repos’ | jq ‘.[] | {name, stars: .stargazers_count}’ kubectl get pods -o json | jq ‘.items[] | select(.status.phase != “Running”) | .metadata.name’ cat app.log | jq -c ‘select(.level == “error”) | {time: .timestamp, msg: .message}’

jq je nezbytný

Pro API a JSON data jq dramaticky zrychlí práci.

jqjsonclilinux
Share:

CORE SYSTEMS tým

Stavíme core systémy a AI agenty, které drží provoz. 15 let zkušeností s enterprise IT.