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 {};
};
};

posted @ 2016-06-28 14:49  溜溜达达  阅读(379)  评论(0编辑  收藏  举报