Converting a string to JSON object
var obj = JSON.parse(string);
Where string
is your json string.
You can use the JSON.parse()
for that.
See docs at MDN
Example:
var myObj = JSON.parse('{"p": 5}');
console.log(myObj);
var obj = JSON.parse(string);
Where string
is your json string.
You can use the JSON.parse()
for that.
See docs at MDN
Example:
var myObj = JSON.parse('{"p": 5}');
console.log(myObj);