safeParseStrict
Parses strict JSON like parseStrict, but returns null (or fallback) instead of
throwing on invalid input.
Accepts / rejects: exactly what parseStrict does — standard JSON only, no comments, no trailing commas, no JSON5 syntax, no leading byte order mark.
On invalid input: returns fallback when one is given — even undefined, which is told
apart from an omitted argument — and null otherwise. Never throws.
Available since v3.1.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
text | string | The JSON text to parse |
Returns
Section titled “Returns”T | null — The parsed value typed as T, or null on invalid input (pass a fallback to get it instead)
Examples
Section titled “Examples”Parse without throwing
Section titled “Parse without throwing”Returns null instead of throwing on invalid input.
Provide a fallback
Section titled “Provide a fallback”The fallback is returned on invalid input, so the result is never null.
