June 2014
Intermediate to advanced
696 pages
38h 52m
English
A JSON string represents a JavaScript object in string form. The string syntax is very similar to code, so it’s easy to understand. You can use the JSON.parse(string) method to convert a string that is properly formatted with JSON into a JavaScript object.
For example, in the following code snippet, notice that accountStr is defined as a formatted JSON string, then converted to a JavaScript object using JSON.parse() and then member properties can be accessed via dot notation:
var accountStr = '{"name":"Jedi", "members":["Yoda","Obi Wan"], \ "number":34512, "location": "A galaxy far, far away"}';var accountObj = JSON.parse(accountStr);console.log(accountObj.name); ...
Read now
Unlock full access