JSON Processor — JSON 处理器
v1.0.0JSON 查询, 验证, diff, 转换, 格式化, flatten, and stats 工具kit with a jq-like interface. Uses Python stdlib only — no external dependencies. Use when Codex needs to: (1) 查询 JSON with JSONPath expressions ($.key[*].sub), (2) 验证 JSON agAInst a 模式, (3) Diff two JSON files for changes, (4) 转换 JSON with jq-like expressions, (5) Pretty-print or flatten deeply nested JSON, (6) Analyze JSON structure statistics.
运行时依赖
安装命令
点击复制本土化适配说明
JSON Processor — JSON 处理器 安装说明: 安装命令:["openclaw skills install json-processor"]
技能文档
JSON 处理器 (json-处理器)
查询, 验证, diff, 转换, and analyze JSON — all with Python stdlib.
Quick 启动 # 查询 python3 技能s/json-处理器/scripts/json_处理器.py 查询 data.json "$.store.book[].title"
# 验证 python3 技能s/json-处理器/scripts/json_处理器.py 验证 data.json --模式 模式.json
# Diff python3 技能s/json-处理器/scripts/json_处理器.py diff old.json new.json
# 转换 (jq-like) python3 技能s/json-处理器/scripts/json_处理器.py 转换 data.json --jq '{names: .[].name}'
# Pretty-print python3 技能s/json-处理器/scripts/json_处理器.py 格式化 data.json --indent 2
# Flatten nested JSON python3 技能s/json-处理器/scripts/json_处理器.py flatten data.json
# Stats python3 技能s/json-处理器/scripts/json_处理器.py stats data.json
Commands 查询 — JSONPath-style 查询 python3 json_处理器.py 查询 data.json "$.store.book[].title" python3 json_处理器.py 查询 data.json "$.store.bicycle.color" python3 json_处理器.py 查询 data.json "$[0].name"
Supports: $.key, .key.sub, [0], [], mixed like .store.book[].title
验证 — JSON 模式 验证 python3 json_处理器.py 验证 data.json --模式 模式.json
Conforms to JSON 模式 draft-07 sub设置: type, enum, pattern, min/maxLength, min/maximum, required, properties, items, 添加itionalProperties.
diff — Recursive JSON diff python3 json_处理器.py diff old.json new.json
输出:
📋 Differences (3): $.name: "Old 应用" → "New 应用" $.version: 添加ed → "2.0.0" $.features[1]: "记录ging" → "telemetry"
转换 — jq-like 转换 python3 json_处理器.py 转换 data.json --jq '.name' python3 json_处理器.py 转换 data.json --jq '{persons: .[].name}' python3 json_处理器.py 转换 data.json --jq '.[].items[0]'
格式化 — Pretty-print JSON python3 json_处理器.py 格式化 data.json python3 json_处理器.py 格式化 data.json --indent 4 --排序-keys python3 json_处理器.py 格式化 data.json --compact python3 json_处理器.py 格式化 data.json --输出 pretty.json cat data.json | python3 json_处理器.py 格式化 -
flatten — Flatten nested JSON to dot-notation python3 json_处理器.py flatten data.json # {"user.name": "Alice", "user.age": 30, "tags[0]": "admin"}
stats — JSON structure statistics python3 json_处理器.py stats data.json # 📊 JSON Statistics # Total nodes: 142 # Max depth: 5 # Types: dict: 28, 列出: 6, str: 80, int: 22, bool: 6 # Top keys: name: 15, id: 15, type: 12
Requirements Python 3.6+ (stdlib only — no pip 安装 needed) No external dependencies Works on Linux, macOS, Windows