360 Secure SkillHub
360 安全技能中心

Jsonpretty

对 JSON 做美化输出、语法校验、点号路径查询(支持数组索引)、嵌套结构扁平化、键数量/深度/类型分布统计、压缩输出与键排序;支持从文件或标准输入读取,零第三方依赖,纯 Python 实现。

rogue-agent1
rogue-agent1
热度 54.87
最近更新 2026-05-11 17:37:27
分类:效率依赖:代码执行 / 读写文件应用场景:数据处理

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add jsonpretty
Metadata
name
jsonpretty
description
Format, validate, query, flatten, and analyze JSON data. Use when asked to pretty-print JSON, validate JSON syntax, query nested JSON with dot-notation, flatten nested structures, get JSON statistics, or compact JSON output. Reads from files or stdin pipe. Zero dependencies — pure Python.

jsonpretty 📋

JSON swiss army knife — format, validate, query, flatten, stats.

Commands

# Pretty-print (from file or stdin)
python3 scripts/jsonpretty.py data.json
echo '{"a":1}' | python3 scripts/jsonpretty.py

# Validate JSON
python3 scripts/jsonpretty.py --validate data.json

# Query with dot-notation
echo '{"user":{"name":"Rogue"}}' | python3 scripts/jsonpretty.py -q "user.name"

# Flatten nested JSON
cat data.json | python3 scripts/jsonpretty.py --flat

# Structure stats (key count, depth, types, size)
python3 scripts/jsonpretty.py --stats data.json

# Compact output (minify)
python3 scripts/jsonpretty.py --compact data.json

# Sort keys
python3 scripts/jsonpretty.py --sort data.json

Features

  • Pretty-print with 2-space indent (default)
  • JSON validation with error messages
  • Dot-notation querying (supports array indices: key[0].sub)
  • Flatten nested objects to key.subkey = value pairs
  • Structure statistics: key count, nesting depth, type distribution, byte size
  • Compact/minify mode
  • Sorted key output
  • Reads from file or stdin