Parses untrusted JSON without throwing on invalid syntax.
Parsing does not validate the result's shape. Callers must check the fields they need, even when they supply a type argument.
const input = Json.parse<{ symbol?: string }>(await request.text())if (!input) { return fail('Body must be valid JSON')} Copy
const input = Json.parse<{ symbol?: string }>(await request.text())if (!input) { return fail('Body must be valid JSON')}
Bayu Dwiyan Satria
1.0.0
1.3.0
Static
Parses JSON, returning null for empty input, invalid syntax, or a null literal.
The expected shape, which is not validated.
The raw text to parse.
The parsed value, including valid primitives, or null.
Parses untrusted JSON without throwing on invalid syntax.
Remarks
Parsing does not validate the result's shape. Callers must check the fields they need, even when they supply a type argument.
Example
Author
Bayu Dwiyan Satria
Version
1.0.0
Since
1.3.0