To convert string to JSON in JavaScript, use the
JSON.parse
function.Here's how you do it:
const string = '{ "Hello": "World!" }';
const json = JSON.parse(string);
console.log(json); // { Hello: 'World!' }
JSON.parse
function.Here's how you do it:
const string = '{ "Hello": "World!" }';
const json = JSON.parse(string);
console.log(json); // { Hello: 'World!' }