I have data in this format:
var data = "{"attr":"value","html":"<div><div style="left: 0px;"></div></div>"}";
There is more to the html, but its not required here. I try to do:
data = JSON.parse(data)
This errors giving:
Uncaught SyntaxError: Unexpected token l
Due to the additional " in the style. How do you correctly parse this?
edit:
I am getting data from a server, so I receive it in a websocket such as:
sock.onmessage = function(message) {
//Need to parse this.
data = message.data
console.log(typeof data); // = string
console.log(data);
//console.log(data) result
//{"attr":"value","html":"<div><div style="left: 0px; width: 100%; height: 0px; position: relative; padding-bottom: 56.2493%;">Content</div></div>"}
}