Loading editor...
C # BackgroundCodeThis article Reprinted from http://www.cnblogs.com/ITniao/archive/2011/01/06/1929261.html (IT) bird in ASP.. Net JSON processing usually involves the use of single quotes or other special characters. If you use it directly, the JSON data will be truncated, causing JS errors to fail to run correctly. In fact, you only need to use the Javascript escape method to encode the string to solve this problem. But how can we solve this problem in C # code? We naturally thought of using the server. urlencode method to encode data. However, after practice, we found that some characters After encoding cannot be restored by the Unescape method in JS. In fact, the solution is very simple. Reference Microsoft. JScriptProgramSet, use the escape method of the globalobject class. This method works similar to server. urlencode, but it calls the Javascript escape method in the C # code, which can be restored by the Unescape method.
Microsoft. JScript. globalobject. Escape (strjs) in. CS );
VaR csstr = Unescape (JSON. csstr );