Aller au contenu
uencoder

JSONC (JSON avec Comments) Specification

JSONC est JSON avec ligne et bloc comments, utilisé par VS Code et TypeScript configuration fichiers.

Comment Support

JSONC extends JSON with // line comments and /* block comments */. No other syntax changes are made; trailing commas and unquoted keys remain disallowed. The format is used by VS Code settings, tsconfig.json, and other configuration files. JSONC parsers strip comments before standard JSON parsing. The format is a minimal, pragmatic extension for configuration.

line comments
// style
VS Code settings
block comments
/* */ style
tsconfig.json
no other changes
Strict JSON otherwise
minimal extension

Parsing Strategy

Most JSONC implementations preprocess input to remove comments before JSON.parse. TypeScript provides native JSONC parsing via tsconfig APIs. VS Code has a built-in JSONC parser with schema validation. The format is not suitable for data interchange due to non-standard parsers. For programmatic config, JSONC offers the simplest extension over JSON.

preprocess
Strip then parse
common approach
TypeScript
Native parse API
ts.readConfigFile
VS Code
Built-in parser
jsonc-parser

Outils associés

参考链接