zoukankan      html  css  js  c++  java
  • Newtonsoft.Json.Linq对象读取DataSet数据

    Newtonsoft.Json.Linq对象读取DataSet数据:

    private void button4_Click(object sender, EventArgs e)
            {
                DataTable dt = new DataTable("t");
                dt.Columns.Add("a");
                dt.Columns.Add("b");
                dt.Rows.Add("1", "11");
                dt.Rows.Add("2", "22");

                DataSet ds = new DataSet();
                ds.Tables.Add(dt);

                dt = dt.Copy();
                dt.TableName = "t2";
                ds.Tables.Add(dt);
                string str = Newtonsoft.Json.JsonConvert.SerializeObject(ds);

                object obb = Newtonsoft.Json.JsonConvert.DeserializeObject(str);

                //string ss= obb["a"];
                JObject ob = (JObject)(obb);
                JArray ss = (JArray) ob["t"];
                JObject jo = (JObject)ss[0];
                string mm = jo["a"].ToString();
            }

            private void button5_Click(object sender, EventArgs e)
            {
                Dictionary<string, string> dict = new Dictionary<string, string>();
                dict["a"] = "111";
                dict["b"] = "dsf";
                dict["c"] = "dssssf";

                string str = Newtonsoft.Json.JsonConvert.SerializeObject(dict);

                object obb = Newtonsoft.Json.JsonConvert.DeserializeObject(str);
             
                //string ss= obb["a"];
                JObject ob =  ( JObject)(obb);
                string mm = ob["a"].ToString();
            }

  • 相关阅读:
    1004 Counting Leaves
    1003 Emergency (25分)
    1002 A+B for Polynomials (25分)
    1001 A+B Format
    Weekly Contest 139
    491. Increasing Subsequences
    488. Zuma Game
    servlet总结
    firefox插件Firebug的使用教程
    KMP---POJ 3461 Oulipo
  • 原文地址:https://www.cnblogs.com/81/p/9906506.html
Copyright © 2011-2022 走看看