parseJsonSafe
Parses JSON from untrusted input and rejects what could pollute a prototype later: a __proto__ key anywhere, a constructor or prototype key holding an object, and nesting deeper than 64 levels.
Parses JSON from untrusted input and rejects what could pollute a prototype later: a
__proto__ key anywhere, a constructor or prototype key holding an object, and nesting
deeper than 64 levels.
Import#
ts
import { parseJsonSafe } from "@shadow-js/dusk/server";
Signature#
ts
function parseJsonSafe(source: string): unknown
Parameters#
| Name | Description |
|---|---|
source |
JSON text. |
Returns#
The parsed value.
Throws#
- HttpError 400 for invalid JSON, a forbidden key or excessive depth.
Examples#
ts
const body = parseJsonSafe(await request.text());