Standard built-ins
JSON.parse()
Parse JSON text to JavaScript values. Invalid text throws SyntaxError. Optional reviver transforms values bottom-up. Validate expected data shape separately.
Formal Syntax & Structure
javascript syntaxjavascript
JSON.parse(text, [reviver])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| text | String | JSON text. |
| reviver | Function | Optional transform after parsing. |
Return Value
Any
Parsed or revived value.
Working Example
Example Snippetjavascript
console.log(JSON.parse('{"n":3}').n);