JSON.parse()
ES5+Parses a JSON string, constructing the JavaScript value or object described by the string.
Syntax
JSON.parse(text, reviver)Parameters
text string The string to parse as JSON
reviver Function optionalA function that transforms the results
Return Value
any
The JavaScript value corresponding to the given JSON text
Examples
JavaScript
const json = '{"name":"John","age":30}';
const obj = JSON.parse(json);
console.log(obj.name);
console.log(obj.age); Output:
// 'John'
30