Answers for "convert string to object in javascript"

19

turn object into string javascript

var obj = {a: "a", b: "b" /*...*/};
var string = JSON.stringify(obj);
// OUTPUT:
// "{'a':'a', 'b':'b'}"
Posted by: Guest on March-19-2020
4

convert string to object javascript

var mystr = '{ "hello":"world" }' // NB: Has enclosing ""
var myobj = JSON.parse(mystr);
Posted by: Guest on November-04-2020
0

convert strings to object javascript

const obj = JSON.parse('{"assetType": "OPTION", 
"putCall ": "CALL", 
"contractType": "CALL", 
"strikePrice": "700", 
"premium": "6.00", 
"comment": "", 
"parsed": true }');
Posted by: Guest on June-28-2021
0

convert string to object javascript

str = "firstName:name1, lastName:last1"; // NB: No enclosing ""
obj = eval('({' + str + '})');
Posted by: Guest on November-04-2020

Code answers related to "convert string to object in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language