Diaosi skills -- convert to Json (Newtonsoft. Json. dll), newtonsoft. json. dll

Source: Internet
Author: User

Diaosi skills -- convert to Json (Newtonsoft. Json. dll), newtonsoft. json. dll

Mom no longer worries about converting Json !!

It's very simple. There's nothing to explain, um!

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 void Page_Load(object sender, EventArgs e) 2         { 3             if (!IsPostBack) 4             { 5                 ToJsonGetData tjgd = new ToJsonGetData(); 6                 DataTable dt = tjgd.GetData1(); 7                 ShowTablePage stp = new ShowTablePage { total = dt.Rows.Count, rows = dt }; 8                 var obj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.Linq.JToken.FromObject(stp); 9                 string json = obj.ToString();10 11 12                 List<ToJsonENTITY> listEn = tjgd.GetData2();13                 ShowTablePage<ToJsonENTITY> stp2 = new ShowTablePage<ToJsonENTITY> { total = listEn.Count, rows = listEn };14                 obj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.Linq.JToken.FromObject(stp2);15                 json = obj.ToString();16 17                 Response.Write(json);18             }19         }
View Code

 

 

Download: Json.dll.7z

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.