Expand description
NDJSON-safe JSON serialization.
JSON.stringify emits U+2028/U+2029 raw (valid per ECMA-404). When the output is a single NDJSON line, any receiver that uses JavaScript line-terminator semantics (ECMA-262 §11.3 — \n \r U+2028 U+2029) to split the stream will cut the JSON mid-string.
The \uXXXX form is equivalent JSON but can never be mistaken for a line terminator by ANY receiver.
Functions§
- escape_
unicode_ line_ separators - Escape U+2028/U+2029 in an arbitrary string (not just JSON). Useful for session transcript content that may contain these characters.
- serialize_
to_ ndjson - Serialize any serde value to NDJSON-safe JSON.
- serialize_
to_ ndjson_ safe - Serialize a JSON value to NDJSON-safe string, falling back to empty string on error.