解析 JSON5 — JSON with relaxed syntax
JSON5 extends JSON 具有 comments, trailing commas, unquoted 关键, 单个 quotes, 和更多. Learn syntax extensions 和 conversion 到标准 JSON.
- 1
JSON5 allows: single-quoted strings, unquoted object 关键 (如果它们是 有效 identifiers), trailing commas, comments (// 和 /* */), 十六进制 numbers, Infinity/NaN, 和 multi-行 strings. 它是 useful 为配置 files where human readability matters.
- 2 JSON 格式化器 →
Paste JSON5 内容和 格式化它 as 标准 JSON. 此 strips comments, converts 单个 quotes 到双 quotes, quotes 所有关键, 和 removes trailing commas — producing 有效 JSON 该任何 parser 能够读取.
- 3 JSON 验证器 →
验证 the converted JSON to ensure it is syntactically correct. JSON5 features that were stripped (comments, trailing commas) do not appear in standard JSON — verify nothing was lost in conversion.
- 4
JSON5 是 primarily 为 human-authored 配置. 从不 use 它为 数据 interchange — 标准 JSON 是 universally supported. Convert JSON5 到 JSON 在构建时间, 不 runtime, 到 avoid shipping JSON5 parser 到客户端.
常见问题
- 是 JSON5 replacement 为 JSON?
- 否. JSON5 是超集的 JSON 为 human-authored files (configs, fixtures). 为数据 interchange (APIs, storage), use 标准 JSON — 它是 universally supported 和有 否 parser ambiguity.
- 能够 I use JSON5 在 my 构建 tool?
- 是. 许多 tools (Vite, ts-节点, Babel) 支持 JSON5 配置 files. 它们解析 JSON5 在 startup 和转换到 JSON 内部. Check 你的 tool's 文档为 JSON5 支持.