JSON.parse
Summary
Parse a JSON string to a JavaScript object.
Syntax
var = JSON.parse(json string);
Parameters
json string
- Data-type
- String
A JSON string.
Return Value
Returns an object of type
A JavaScript object representing the JSON string.
Examples
var json = '{"result":true,"count":1}',
obj = JSON && JSON.parse(json)
Notes
This method will throw an error if the argument is not a valid JSON string. You should wrap the parse call in a try/catch block.
Related specifications
- JSON-LD 1.0
- W3C Recommendation