简体   繁体   中英

unescaping \" in javascript

I get a JSON object returned to me as follows:

result: {
 image: "..."
 title: "text text \"text\""
}

I am using underscore.js to render the template however when when it displays the title it includes the \\" in the text.

eg text text \\"text\\"

How can I unescape the the double quotes before displaying?

Thanks

.replace 可以做到:

text = result.text.replace(/\\([\\"])/g, '$1');

This link might be helpful, but I see in your comments that you are getting exactly same data as you have mentioned, so:

 var result = { image: "...", title: "text text \\"text\\"" } alert (result.title.toString().replace(/"/g, ''));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM