js处理服务器返回的字符串

function FormatJSON(Str) {
try{
Str = Str.replace(/\/g, "");
Str = Str.replace(/(^"{1})|("{1}$)/g, "");
Str = Str.replace(/(^(null(){1})|(()){1}$)/g, "");
Str = JSON.parse(Str);
return Str;
}catch(e){
return {};
};
};

原文地址:https://www.cnblogs.com/aiwoqu/p/5623412.html