[Solved] how to parse string into json object javascript [duplicate]


You can replace single quotes to double quotes and parse it.

var str =  "{'firstname':'Jesper','surname':'Aaberg','phone':'555-0100'}";

var o = JSON.parse(str.replace(/\'/g, "\""));
console.log(o)

1

solved how to parse string into json object javascript [duplicate]