JObject staff = new JObject();
staff.Add(new JProperty("Name", "Jack"));
staff.Add(new JProperty("Age", 33));
staff.Add(new JProperty("Department", "Personnel Department"));
staff.Add(new JProperty("Leader", new JObject(new JProperty("Name", "Tom"), new JProperty("Age", 44), new JProperty("Department", "Personnel Department"))));
Console.WriteLine(staff.ToString());
JArray arr = new JArray();
arr.Add(new JValue(1));
arr.Add(new JValue(2));
arr.Add(new JValue(3));
Console.WriteLine(arr.ToString());
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());