How do you parse JSON string
When receiving the data from a web server, the data is always in a string format. But you can convert this string value to a javascript object using parse() method.
1 2 3 | var userString = '{"name":"John","age":31}'; var userJSON = JSON.parse(userString); console.log(userJSON);// {name: "John", age: 31} |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.