Skip to main content

Module json

Module json 

Source
Expand description

JSON string encoding, shared by every artifact this workspace writes. 本工作区写出的每个 JSON 工件共用的 JSON 字符串编码。

Three artifacts need it, and they used to disagree: the build-diagnostics document, the MIR JSONL artifact, and the generated editor-snippet file. Two of the three carried a private “replace \ and "” copy, which is not JSON encoding at all — RFC 8259 also requires every code point below U+0020 to be escaped — so those two could emit a raw tab or newline inside a string. 有三份工件需要它,而它们此前并不一致:构建诊断文档、MIR JSONL 工件、以及生成的编辑器 片段文件。其中两份各带一份私有的“只替换 \ 与 "”副本,那根本不是 JSON 编码—— RFC 8259 还要求转义所有低于 U+0020 的码点——因此那两份会在字符串里原样写出制表符或换行。

Functions§

json_string
Encode value as a complete JSON string, quotation marks included. 把 value 编码为完整的 JSON 字符串,含两侧引号。
push_json_string
Append value to output as one quoted JSON string literal. 把 value 作为一个带引号的 JSON 字符串字面量追加到 output。