Install
openclaw skills install json-query-tool-kayQuickly extract and filter JSON fields using simple path expressions with optional output as raw, JSON, or tables, without complex syntax or extra dependencies.
openclaw skills install json-query-tool-kayjsonq <文件> <路径表达式>
jsonq <文件> <路径> --format raw|json|table
| 模式 | 说明 | 示例 |
|---|---|---|
key | 对象属性访问 | users.name |
parent.child | 嵌套访问 | user.profile.email |
[n] | 数组索引 | users[0] |
[*] | 全部数组元素 | users[*] |
* | 通配符键名 | users.*.name |
:type | 类型过滤 | age:number |
{
"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"