Jq Json Processor

Process, filter, and transform JSON data using jq - the lightweight and flexible command-line JSON processor.

Zainstaluj
$clawhub install jq-json-processor

jq JSON Processor

Process, filter, and transform JSON data with jq.

Quick Examples

Basic filtering


# Extract a field
echo '{"name":"Alice","age":30}' | jq '.name'

# Output: "Alice"

# Multiple fields
echo '{"name":"Alice","age":30}' | jq '{name: .name, age: .age}'

# Array indexing
echo '[1,2,3,4,5]' | jq '.[2]'

# Output: 3

Working with arrays


# Map over array
echo '[{"name":"Alice"},{"name":"Bob"}]' | jq '.[].name'

# Output: "Alice" "Bob"

# Filter array
echo '[1,2,3,4,5]' | jq 'map(select(. > 2))'

# Output: [3,4,5]

# Length
echo '[1,2,3]' | jq 'length'

# Output: 3

Common operations


# Pretty print JSON
cat file.json | jq '.'

# Compact output
cat file.json | jq -c '.'

# Raw output (no quotes)
echo '{"name":"Alice"}' | jq -r '.name'

# Output: Alice

# Sort keys
echo '{"z":1,"a":2}' | jq -S '.'

Advanced filtering


# Select with conditions
jq '[.[] | select(.age > 25)]' people.json

# Group by
jq 'group_by(.category)' items.json

# Reduce
echo '[1,2,3,4,5]' | jq 'reduce .[] as $item (0; . + $item)'

# Output: 15

Working with files


# Read from file
jq '.users[0].name' users.json

# Multiple files
jq -s '.[0] * .[1]' file1.json file2.json

# Modify and save
jq '.version = "2.0"' package.json > package.json.tmp && mv package.json.tmp package.json

Common Use Cases

Extract specific fields from API response:

curl -s https://api.github.com/users/octocat | jq '{name: .name, repos: .public_repos, followers: .followers}'

Convert CSV-like data:

jq -r '.[] | [.name, .email, .age] | @csv' users.json

Debug API responses:

curl -s https://api.example.com/data | jq '.'

Tips

  • Use -r for raw string output (removes quotes)

  • Use -c for compact output (single line)

  • Use -S to sort object keys

  • Use --arg name value to pass variables

  • Pipe multiple jq operations: jq '.a' | jq '.b'

Documentation

Full manual: https://jqlang.github.io/jq/manual/ Interactive tutorial: https://jqplay.org/

Szczegóły

Wersja
v1.0.0
Pobrania
2,097

Popularne Skills

self-improving-agent
Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Claude ('No, that's wrong...', 'Actually...'), (3) User requests a capability that doesn't exist, (4) An external API or tool fails, (5) Claude realizes its knowledge is outdated or incorrect, (6) A better approach is discovered for a recurring task. Also review learnings before major tasks.
AI Persona OS
The complete operating system for OpenClaw agents. Now with 13 Iconic Character souls (Thanos, Deadpool, JARVIS, Mary Poppins, Darth Vader, and more), SOUL.md Maker (deep SOUL.md builder interview), 11 original personality souls, soul blending, and the full soul gallery. Plus: zero-terminal agent-driven setup, quick-start persona presets, in-chat commands, ambient context monitoring, enforced heartbeat protocol (model + version display), traffic-light status indicators, auto-migration, auto-pruning, config validator, version tracking, structured escalation protocol, context protection, security inoculation, shared-channel discipline, team integration, proactive patterns, never-forget protocol, 8 operating rules, and 4 growth loops. One install. Complete system. Built by Jeff J Hunter.
Security Auditor
Use when reviewing code for security vulnerabilities, implementing authentication flows, auditing OWASP Top 10, configuring CORS/CSP headers, handling secrets, input validation, SQL injection prevention, XSS protection, or any security-related code review.