[英]How to escape double quote in JSON string
You just need to escape the backslash \
, so it turns into two backslashes \\
你只需要转义反斜杠\
,所以它变成两个反斜杠\\
console.log(JSON.parse('{"x":"Hello \\" test"}'))
let mydata = `{"x":"Hello \" test "}` let escapeJsonFunc = function(str) { return str.replace(/\\/g,'\\'); }; console.log( escapeJsonFunc(mydata) )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.