🦀 ClawHub
JSON Query Tool
by @shenghoo123-png
Quickly extract and filter JSON fields using simple path expressions with optional output as raw, JSON, or tables, without complex syntax or extra dependencies.
TERMINAL
clawhub install json-query-tool-kay📖 About This Skill
json-query-tool — JSON 查询工具
痛点
场景
定价
指令格式
基本用法
jsonq <文件> <路径表达式>
输出格式
jsonq <文件> <路径> --format raw|json|table
查询语法
| 模式 | 说明 | 示例 |
|------|------|------|
| key | 对象属性访问 | users.name |
| parent.child | 嵌套访问 | user.profile.email |
| [n] | 数组索引 | users[0] |
| [*] | 全部数组元素 | users[*] |
| * | 通配符键名 | users.*.name |
| :type | 类型过滤 | age:number |
示例
示例 JSON
{
"users": [
{"name": "Alice", "age": 30, "email": "alice@example.com"},
{"name": "Bob", "age": 25, "email": "bob@example.com"}
],
"company": {
"name": "TechCorp",
"departments": [
{"name": "Engineering", "head": "Carol"},
{"name": "Sales", "head": "Dave"}
]
}
}
查询示例
# 获取所有用户名
jsonq data.json "users[*].name"
["Alice", "Bob"]获取第一个用户的邮箱
jsonq data.json "users[0].email"
alice@example.com获取部门名称列表
jsonq data.json "company.departments[*].name"
["Engineering", "Sales"]表格形式输出
jsonq data.json "users[*]" --format table
name age email
Alice 30 alice@example.com
Bob 25 bob@example.com类型过滤:只取数字字段
jsonq data.json "users[0]" --format json
{"name": "Alice", "age": 30, "email": "alice@example.com"}
安装
# 本地安装
pip install -e .或直接使用
chmod +x jsonq
./jsonq data.json "field"