Javascript: Escaping the "Double Quotes" in JSON String while parsing?

ساخت وبلاگ

Vote count: 0

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?

asked 51 secs ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : javascript escape the room game,javascript escape the backslash,javascript escape the escape character, نویسنده : استخدام کار backsoft بازدید : 296 تاريخ : دوشنبه 29 شهريور 1395 ساعت: 5:32