This post will discuss how to parse a JSON string to an Object in JavaScript.

1. Using JSON.parse() function

JavaScript provides the native implementation of JSON.parse() method to parse the string. It returns the object corresponding to the given JSON string or throws a SyntaxError when the string is invalid JSON.

Download  Run Code

 
To do the reverse, call the JSON.stringify() method.

Download  Run Code

2. Using jQuery

The jQuery library also has the $.parseJSON() method. This method is deprecated now, and it is recommended to use the native JSON.parse() method instead of parsing JSON strings.

Download Code

That’s all about parsing a JSON string to an object in JavaScript.