InterviewHubPRO
Section Overview
Q119

Question 119 of 521

Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

23%
JavaScript Internals (521 Qs)•Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

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.

javascript
  var userString = '{"name":"John","age":31}';
  var userJSON = JSON.parse(userString);
  console.log(userJSON); // {name: "John", age: 31}