by @saigowthamr

How to convert a JSON string into a JavaScript object

Home » javascript » How to convert a JSON string into a JavaScript object

To convert a JSON string into a JavaScript object we can use the JSON.parse() method by passing the string as an argument to it.

Here is an example that converts the user JSON string to a JavaScript object.

const userString = '{"name":"coach","age":12,"active":false}';

const userObject = JSON.parse(userString);

console.log(userObject);

Output:

 {
 active: false,
 age: 12,
 name: "coach"
}

Best Web Development courses