Newtonsoft.Json.Linq對象讀取DataSet數據
阿新 • • 發佈:2018-11-05
sof json bject 數據 bsp copy convert .json tostring 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();
}
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();
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"];
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["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();
}
Newtonsoft.Json.Linq對象讀取DataSet數據