跳到正文
TakoAPI
返回技能列表

json-repair-kit

由 wanng-ide 提供

PDF & Documents
502下载量由 clawskills.sh 提供
1浏览量
0 个赞登录后即可为这个技能点赞
—暂无评分
你的评分

简介

Repair malformed JSON files by normalizing them through Node.js evaluation.

描述

该技能的功能

Repairs malformed JSON files by parsing them as JavaScript objects and re-serializing as strict JSON. Handles trailing commas, single quotes, unquoted keys, JS-style comments, and hex/octal numbers. Operates on single files or entire directories recursively.

Uses vm.runInNewContext instead of direct eval, making it safer than regex-based fixers while handling a broader set of syntax errors in one pass.

何时使用

  • Fixing config files with trailing commas added by hand-editing
  • Converting JS object literals copied into .json files
  • Batch-repairing all JSON files in a project directory
  • Normalizing JSON exported from tools using loose syntax
  • Recovering manually edited data files with mixed quote styles

示例工作流

输入

User asks: Repair my broken config.json that has trailing commas and unquoted keys

智能体
  1. 1

    Identifies the broken JSON file at the specified path

  2. 2

    Creates a .bak backup of the original file

  3. 3

    Parses the file content using vm.runInNewContext as a JavaScript object

  4. 4

    Re-serializes the result as valid JSON

  5. 5

    Validates the output before writing it back to disk

输出

config.json is overwritten with valid JSON; config.json.bak preserves the original

安装

clawhub install wanng-ide/json-repair-kit

运行 CLI 命令,或把这段提示词粘贴到 Claude Code、Cursor、Codex 或你在用的任意编程智能体里。

链接