javascript convert string to json object
// Imagine we received this text from a web server:
'{ "name":"John", "age":30, "city":"New York"}'
// To convert text into a JavaScript object, use the JavaScript function JSON.parse():
var obj = JSON.parse('{ "name":"John", "age":30, "city":"New York"}');
// OR
var string = '{ "name":"John", "age":30, "city":"New York"}';
var obj = JSON.parse(string);