A utility to repair broken or "loose" JSON files (like those with trailing commas, single quotes, or unquoted keys) by parsing them as JavaScript objects and re-serializing as valid JSON.
# Repair a file in place (creates .bak backup)
node skills/json-repair-kit/index.js --file path/to/broken.json
# Repair and save to a new file
node skills/json-repair-kit/index.js --file broken.json --out fixed.json
# Scan directory and repair all .json files (recursive)
node skills/json-repair-kit/index.js --dir config/ --recursive
{"a": 1,} -> {"a": 1}{'a': 'b'} -> {"a": "b"}{key: "value"} -> {"key": "value"}// (if parser supports it, standard Node eval may strip them if they are line comments outside of strings).0xFF -> 255.bak file before overwriting (unless --no-backup is used, but default is safe).vm.runInNewContext to parse, ensuring no access to global scope or process. It is safer than eval().共 1 个版本