Quote a value for an error message, as JSON.stringify does, and also escape what it
leaves raw although a terminal acts on it or a reader can't see it: DEL, the C1 controls,
every Unicode format character (bidi overrides, zero-width characters, the soft hyphen) and
the line and paragraph separators U+2028/U+2029, which a viewer may break the line at; a
lone surrogate comes out as its \ud800 escape (JSON.stringify's own). So a refusal of
"a\u200bb" shows why the value matched nothing, and an override in it can't reorder the
rest of the line ("Trojan Source"). A value longer than max (MAX_QUOTED_LENGTH, 200)
characters is cut, and the "…" goes after the closing quote ("AAAA"…), so it does not read
as part of the value. The quoted part stays a valid JSON string.
Quote a value for an error message, as
JSON.stringifydoes, and also escape what it leaves raw although a terminal acts on it or a reader can't see it: DEL, the C1 controls, every Unicode format character (bidi overrides, zero-width characters, the soft hyphen) and the line and paragraph separators U+2028/U+2029, which a viewer may break the line at; a lone surrogate comes out as its\ud800escape (JSON.stringify's own). So a refusal of"a\u200bb"shows why the value matched nothing, and an override in it can't reorder the rest of the line ("Trojan Source"). A value longer thanmax(MAX_QUOTED_LENGTH, 200) characters is cut, and the "…" goes after the closing quote ("AAAA"…), so it does not read as part of the value. The quoted part stays a valid JSON string.