If the string contains only double quotes, it can be solved like below-
var str=`{"name":"javascript"}`;
var jsonObj=JSON.parse(str) //Works
And if string contains only single quotes , it can be solved like below-
var str = "{'result': ['def', 'abc', 'xyz']}";
str = str.replace(/'/g, '"');
var res = JSON.parse(str);
console.log(res.result);
But how do we convert the below string, where there's single quote inside the double quote-
var s=`{'error': "No such file or directory: '../FileSystem/3434-5433-124/'"} `