Converting an object into a JSON format is working perfectly fine with the code below:
myStr = "{'key':'value'}"
JSON.parse(myStr.replace(/'/g, "\""));
However, when using the same code with this object:
myStr = "{'key':'val'ue'}"
An error occurs with the message 'unexpected token u'. I want to preserve the single quote between 'l' and 'u', and not replace it. Is there any way to achieve this?