Concepts
JSON reviver callback
Bottom-up transform; undefined removes current property or root result. The root is visited with the empty key, which can also appear in ordinary data.
Formal Syntax & Structure
javascript syntaxjavascript
JSON.parse(text, (key, value) => value)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | String | Current key. |
| value | Any | Value to associate or insert. |
Return Value
Any
Replacement value or undefined.
Working Example
Example Snippetjavascript
console.log(JSON.parse('{"x":"2"}',(k,v)=>k==="x"?Number(v):v).x+1);