返回顶部
j

jq-json-processor

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

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
2,755
下载量
1
收藏
概述
安装方式
版本历史

jq-json-processor

# jq JSON Processor Process, filter, and transform JSON data with jq. ## Quick Examples ### Basic filtering ```bash # 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 ```bash # 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 ```bash # 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 ```bash # 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 ```bash # 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:** ```bash curl -s https://api.github.com/users/octocat | jq '{name: .name, repos: .public_repos, followers: .followers}' ``` **Convert CSV-like data:** ```bash jq -r '.[] | [.name, .email, .age] | @csv' users.json ``` **Debug API responses:** ```bash 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/

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 jq-json-processor-1776378916 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 jq-json-processor-1776378916 技能

通过命令行安装

skillhub install jq-json-processor-1776378916

下载 Zip 包

⬇ 下载 jq-json-processor v1.0.0

文件大小: 1.76 KB | 发布时间: 2026-4-17 15:58

v1.0.0 最新 2026-4-17 15:58
Initial release of jq-json-processor.

- Provides a collection of ready-to-use jq command-line examples for filtering, transforming, and manipulating JSON data.
- Includes common tasks such as field extraction, array operations, advanced filtering, pretty printing, compact and raw output, and file operations.
- Offers practical use cases for APIs, CSV conversion, and debugging.
- Lists installation instructions for jq on common platforms (brew, apt).
- Links to detailed jq documentation and an interactive tutorial.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部