JavaScriptSerializer 对json数据转换


using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Web.Script.Serialization; public partial class Default2 : System.Web.UI.Page {     protected void Page_Load(object sender, EventArgs e)     {         Teacher tc = new Teacher();         tc.TName = "张老师";         tc.TAge = 21;         tc.TAddress = "西单";         JavaScriptSerializer jss = new JavaScriptSerializer();         Response.Write( jss.Serialize(tc));                  Teacher tcnew = jss.Deserialize<Teacher>(jss.Serialize(tc));         Response.Write(tcnew.TAddress);                                              //JavaScriptConverter     } } public class Teacher {     private string _tname;     private int _tage;     private string _taddress;     public string TName     {         get { return _tname; }         set { _tname = value; }     }     public int TAge     {         get { return _tage; }         set { _tage = value; }     }     public string TAddress     {         get { return _taddress; }         set { _taddress = value; }     } }


本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/archive/2011/08/01/2124030.html,如需转载请自行联系原作者
上一篇:使用 Rhino 作为 Java 的 JSON 解析/转换包


下一篇:Android2.2 API 中文文档系列(9) —— ZoomButton