I receive a JSON string returned from a remote Webservice. Something like this:
[{ "id": "001", "link": "<a href="https://www.google.com">Google</a>"
}, { "id": "002", "link": "<a href="https://www.yahoo.com">Yahoo!</a>"
}]
But then when i try to parse it in my Javascript, i have problem parsing it. I tried:
var response_string = '[{"id":"001","link":"<a href="https://www.google.com">Google</a>"},{"id":"002","link":"<a href="https://www.yahoo.com">Yahoo!</a>"}]';
console.log("Output (1) --> ", response_string);
var response_object = JSON.parse(response_string);
console.log("Output (2) --> ", response_object);
Then the outputs are like:
Output (1) --> [{"id":"001","link":"<a href="https://www.google.com">Google</a>"},{"id":"002","link":"<a href="https://www.yahoo.com">Yahoo!</a>"}]
Uncaught SyntaxError: Unexpected token h in JSON at position 30
I guess it is because of double quotes
inside the original JSON String. But how do i escape them or solve this issue properly please?