I’m generating a JSON file using PHP’s json_encode function, and I’ve escaped double-quote characters with ", so the output line looks like this:
"apply_instructions":"<p>Visit <a href="http:\/\/www.google.com">www.google.com<\/a><\/p>"
I’m then using JQuery’s getJSON function to retrieve and loop through the file. I’m attempting to unencode the " using this:
entry.apply_instructions = entry.apply_instructions.replace('"', '"');
For whatever reason, it’s not working. The first quote mark seems to be getting replaced, but the second one won’t budge. I’ve tried using other random find-and-replace characters, with similar results.
.replace()only replaces the first instance, you need to use regex to do a global replace.IE:
.replace(/"/g, "\"");