Recently, I used Asp.net in combination with extjs to develop a news publishing module. I found that extjs grid could not display HTML-tagged news content, and I was puzzled. There were no errors in ff and IE, in addition, in FF debugging, the news content data has been taken out, and the JSON format is correct, but it is not displayed.
Strange!
After repeated research, we found a detail. We copied the news directly from the webpage and pasted it into extjs's htmleditor. The release will contain a lot of \ r \ n tags, as long as it drops, it will be OK, and \ is an escape character, to be processed, otherwise it will not be displayed.
Although the JSON format is simple, it must be organized, otherwise it will not be displayed.
Solution:
It's easy. You only need to replace the news content field. The method to view my ilist2json is as follows:
Public String tojsonstring <t> (string jsonname, ilist il)
{
Stringbuilder JSON = new stringbuilder ();
JSON. append ("{" + jsonname + ":[");
If (IL. Count> 0)
{
For (INT I = 0; I <Il. Count; I ++)
{
T OBJ = activator. createinstance <t> ();
Type type = obj. GetType ();
Propertyinfo [] Pis = type. getproperties ();
JSON. append ("{");
For (Int J = 0; j <PIs. length; j ++)
{
String ilvalue = "";
If (PIS [J]. getvalue (IL [I], null )! = NULL)
{
Ilvalue = Pis [J]. getvalue (IL [I], null ). tostring (). replace ("'","\""). replace ("\ r ",""). replace ("\ n ",""). replace ("\\
', "//"); // The Key is here. Replace the sensitive character with OK.
}
JSON. append ("'" + Pis [J]. Name. tostring () + "': '" + ilvalue + "'");
If (j <PIs. Length-1)
{
JSON. append (",");
}
}
JSON. append ("}");
If (I <Il. Count-1)
{
JSON. append (",");
}
}
}
JSON. append ("]}");
Return JSON. tostring ();
}