The JSON data we usually get in the backend code is as follows:
JSON will contain some special symbols, \ r, \ n, \ and so on. Let's write a method to eliminate these special symbols and get the pure JSON in the code.
1 Public Staticstring Jsonremovesymbols (string s)2 {3StringBuilder SB =NewStringBuilder ();4 for(inti =0; i < s.length; i++)5 {6 Charc =S[i];7 Switch(c)8 {9 Case '\"':TenSb. Append (""); One Break; A Case '\\': -Sb. Append (""); - Break; the Case '/': -Sb. Append (""); - Break; - Case '\b': +Sb. Append (""); - Break; + Case '\f': ASb. Append (""); at Break; - Case '\ n': -Sb. Append (""); - Break; - Case '\ r': -Sb. Append (""); in Break; - Case '\ t': toSb. Append (""); + Break; - default: the sb. Append (c); * Break; $ }Panax Notoginseng } - returnsb. ToString (); the}
This method is to iterate through the JSON data and replace the \ r \ n symbols with an empty string.
Getting JSON data requires removing special symbols