Concepts

JSON reviver callback

Try the free JavaScript compiler

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

NameTypeDescription
keyStringCurrent key.
valueAnyValue 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);
JavaScript Reference