parse
Converts a JSON-formatted string into an object.
const str = `{
"a": 1,
"b": [1, 2, 3]
}`;
const obj = parse(str);
console.log(obj.b); // [ 1, 2, 3 ]
Syntax
parse(json_string)
Returns
The JSON as an object.
Exceptions
Will throw an exception if there is a syntax error in the input string.
- This can be handled in a try-catch block.