360 Secure SkillHub
360 安全技能中心

Shrink JSON in Prompts (TOON Encoder/Decoder)

该 Skill 通过捆绑的 Python 脚本把 JSON 负载编码为紧凑、可逆的 TOON 字符串,并支持解码还原,用于降低提示与工具负载的 token 消耗。提供 encode、decode、schema 三个子命令,可选 schema 键字典模式与 --pretty 包装输出,宣称对 JSON 基本类型无损并拒绝 NaN/Inf 与非字符串键。

分类:效率
zmkkevin
zmkkevin
热度 22.25
最近更新 2026-05-11 17:36:19

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add zmkkevin/toon-json
兼容性
通用兼容
联网要求
不联网
数据出网
数据不出本机
Metadata
name
toon-json
description
Compress, encode, and decode large JSON payloads into a compact, reversible TOON string to reduce token usage in LLM prompts and tool payloads. Use when you need to shrink repeated JSON in prompts ("compress this JSON", "reduce token usage", "encode JSON"), transmit structured data cheaply, or round-trip JSON reliably (encode/decode/validate). Supports schema (key dictionary) mode for additional compression.

toon-json (TOON v1)

Use the bundled script scripts/toon_json.py to encode JSON into a compact TOON string and decode it back losslessly.

Commands

Encode JSON -> TOON

  • Minimal:
python3 scripts/toon_json.py encode < input.json
  • With schema (better compression for repeated keys):
python3 scripts/toon_json.py encode --schema < input.json
  • Pretty wrapper (includes schema metadata):
python3 scripts/toon_json.py encode --schema --pretty < input.json

Decode TOON -> JSON

python3 scripts/toon_json.py decode < input.toon

Derive a schema (key dictionary) from JSON

python3 scripts/toon_json.py schema < input.json

Operational guidance

  • Prefer --schema when:
    • The JSON has many repeated keys (APIs, config blobs, tool outputs)
    • You will send similar objects repeatedly across turns
  • Prefer schema-less mode when:
    • One-shot payloads
    • You want maximum human readability

Safety / correctness

  • The format is designed to be lossless for JSON types: object, array, string, number, boolean, null.
  • Rejects non-JSON numbers (NaN/Inf) and non-string object keys.
  • If decoding fails, re-run with --pretty output on encode to inspect the embedded schema.