JavaScript: JSON.parse

By Xah Lee. Date: . Last updated: .

JSON.parse(json_string)

Convert JSON string to a JavaScript value.

const jsonString = '{"a":3 , "b":[4,2]}';

console.log(
JSON.parse(jsonString)
);

// { a: 3, b: [ 4, 2 ] }

JSON.parse takes optional 2nd arg. For detail, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse

JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

JSON