//解码
function html_decode(str)
{
var s = "";
if (str.length == 0) return "";
s = str.replace(/>/g, "&");
s = s.replace(/</g, "<");
s = s.replace(/>/g, ">");
s = s.replace(/ /g, " ");
s = s.replace(/'/g, "\'");
s = s.replace(/"/g, "\"");
s = s.replace(/<br>/g, "\n");
return s;
}
例子
var str = '{\"time\": \"2022年2月15日11:39:42\", \"volume\": 1, \"content\": \"待广播文本\", \"tTSName\": \"Microsoft Huihui Desktop - Chinese (Simplified)\", \"textCode\": 1, \"playCount\": 10, \"playPrior\": 0, \"targetIds\": [1], \"textSpeed\": 10, \"promptTone\": 0, \"targetType\": 1}'
html_decode(str)
// 输出结果:'{"time": "2022年2月15日11:39:42", "volume": 1, "content": "待广播文本", "tTSName": "Microsoft Huihui Desktop - Chinese (Simplified)", "textCode": 1, "playCount": 10, "playPrior": 0, "targetIds": [1], "textSpeed": 10, "promptTone": 0, "targetType": 1}'