https://www.cnblogs.com/gygang/p/8954376.html
d.data.replace(/LON:/g, "lng:")
string json = "{\"Name\" : \"Jack\", \"Age\" : 34, \"Colleagues\" : [{\"Name\" : \"Tom\" , \"Age\":44},{\"Name\" : \"Abel\",\"Age\":29}] }"; //将json转换为JObject JObject jObj = JObject.Parse(json); //通过属性名或者索引来访问,仅仅是自己的属性名,而不是所有的 JToken ageToken = jObj["Age"]; Console.WriteLine(ageToken.ToString()); jObj["Age"] = 35; Console.WriteLine(jObj.ToString()); JToken colleagues = jObj["Colleagues"]; colleagues[0]["Age"] = 45; jObj["Colleagues"] = colleagues;//修改后,再赋给对象 Console.WriteLine(jObj.ToString()); jObj.Remove("Colleagues");//跟的是属性名称 Console.WriteLine(jObj.ToString()); jObj["Age"].Parent.AddAfterSelf(new JProperty("Department", "Personnel Department")); JObject linda = new JObject(new JProperty("Name", "Linda"), new JProperty("Age", "23")); jObj["Colleagues"].Last.AddAfterSelf(linda); JToken name = jObj.SelectToken("Name"); var names = jObj.SelectToken("Colleagues").Select(p => p["Name"]).ToList(); foreach (var name in names) var tends = from c in jObj.First.First.First.First.Children()
原文地址:https://www.cnblogs.com/yyzyou/p/12165084.html
时间: 2024-10-29 19:19:44