Mom doesn't have to worry about me turning json anymore!!
Very simple, nothing to explain, eh!
public class showtablepage<t> where T:class, new () {public int total {get; set;} Public list<t> rows {get; set;} } public class Showtablepage {public int total {get; set;} Public DataTable rows {get; set;} } public class Showcombobox {public int id {get; set;} public string text {get; set;} public string Group {get; set;} public bool selected {get; set;} Public list<showcombobox> Children {get; set;} } public class resultmessage<t> {public resultmessage () { } public int Code {get; set;} Public T MSG {get; set;} }
1 protected voidPage_Load (Objectsender, EventArgs e)2 {3 if(!IsPostBack)4 {5Tojsongetdata TJGD =NewTojsongetdata ();6DataTable dt =TJGD. GetData1 ();7Showtablepage STP =Newshowtablepage {total = dt. Rows.Count, rows =DT};8 varobj =(Newtonsoft.Json.Linq.JObject) Newtonsoft.Json.Linq.JToken.FromObject (STP);9 stringJSON =obj. ToString ();Ten One AList<tojsonentity> listEn =TJGD. GetData2 (); -Showtablepage<tojsonentity> STP2 =Newshowtablepage<tojsonentity> {total = listen.count, rows =ListEn}; -obj =(Newtonsoft.Json.Linq.JObject) Newtonsoft.Json.Linq.JToken.FromObject (STP2); theJSON =obj. ToString (); - - Response.Write (JSON); - } +}
View Code
Download: json.dll.7z
Cock Silk skills--turn Json (Newtonsoft.Json.dll)