javascript convert string to object code example
Example 1: convert string to object javascript
var mystr = '{ "hello":"world" }'
var myobj = JSON.parse(mystr);
Example 2: json_decode javascript
JSON.parse(jsonToDecode)
Example 3: js string to object
JSON.parse()
Example 4: js string to node
function createElementFromHTML(htmlString) {
var div = document.createElement('div');
div.innerHTML = htmlString.trim();
return div.firstChild;
}
Example 5: convert string to object javascript
str = "firstName:name1, lastName:last1";
obj = eval('({' + str + '})');