I'm stringyfing an object like {'foo': 'bar'}
{'foo': 'bar'}
How can I turn the string back to an object?
You need to JSON.parse() the string.
JSON.parse()
var str = '{"hello":"world"}'; try { var obj = JSON.parse(str); // this is how you parse a string into JSON document.body.innerHTML += obj.hello; } catch (ex) { console.error(ex); }
2.1m questions
2.1m answers
60 comments
57.0k users