json 需替换 特殊字符串

json  需替换 特殊字符串


sourceStr
= sourceStr.Replace("\b", "\\\b");

sourceStr
= sourceStr.Replace("\t", "\\\t");

sourceStr
= sourceStr.Replace("\n", "\\\n");

sourceStr
= sourceStr.Replace("\f", "\\\f");

sourceStr
= sourceStr.Replace("\r", "\\\r");

return sourceStr.Replace("\"", "\\\"");

posted @ 2011-07-10 15:18  wangkangluo1  阅读(3869)  评论(0编辑  收藏  举报