C# 视觉量检测系列(七):视觉与运动控制集成 —— C# 上位机的实时控制之道
2026/8/17 21:05:15
h5嵌入鸿蒙,h5跳到支付宝沙箱版本支付页面时,JSON.parse又报错了,此处有2种解决方式:
方法一:JSON.parse之前将字符串特殊字符处理下
const responseString = responseStr.indexOf("payUrl") == -1 ? responseStr.replace(/\n/g, "\\n") : responseStr.replace(/([{,]\s*"payUrl"\s*:\s*")(.*?)("\s*[,}])/gs, (match, prefix, content, suffix) => { const escaped = content .replace(/\\/g, '\\\\') .replace(/"/g, '\\"') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') .replace(/\t/g, '\\t'); return `${prefix}${escaped}${suffix}`; });方法二:后台base64处理支付宝返回的payUrl字符串,前端再decode处理