Skip to content

Json Helpers

Utility functions for working with json operations.

FunctionDescription
parseParses JSON permissively: strict JSON, JSONC (the dialect of `tsconfig.json` and VS Code’s `settings.json`, also known…
parseLinesParses newline-delimited JSON — one JSON value per line.
parseSequenceParses a JSON text sequence (RFC 7464, `application/json-seq`): records that each start with the ASCII record separator…
parseStrictParses strict JSON (RFC 8259) — exactly what `JSON.parse` accepts, nothing more.
safeParseParses JSON permissively like parse — strict JSON, JSONC (HuJSON, JWCC) and JSON5 — but returns `null` (or `fallback`)…
safeParseLinesParses newline-delimited JSON (NDJSON, JSON Lines) like parseLines, but returns `null` (or `fallback`) instead of throw…
safeParseSequenceParses a JSON text sequence (RFC 7464) like parseSequence, but returns `null` (or `fallback`) instead of throwing on in…
safeParseStrictParses strict JSON like parseStrict, but returns `null` (or `fallback`) instead of throwing on invalid input.
stringifySerializes a value to JSON text — pretty-printed with 2 spaces by default, or canonical.
stringifyLinesSerializes values as newline-delimited JSON — one compact JSON value per line, each followed by `\n`.
stringifySequenceSerializes values as a JSON text sequence (RFC 7464, `application/json-seq`): each value is written as the ASCII record…