如题:
"CategoryData": [ { "Title": "就诊一般信息", "CategoryId": 1, "ClickType": 1, "Template": "里面是vue定义的模板", "List": { "Table": [ { "Id": "0002ed1c-becd-11e6-93fc-0050568a41b5", "RegTypeName": "副高", "AcceptedPhysicianCode": null, "AssignedPatientLocationNurseUnitCode": "1030700" }]} }
现在 想 把List下多余的 Table去掉,怎么解决呢? 用的NetTownSoft.Josn包。
public async Task<ActionResult> Index(string pId="") { if (HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest") { JObject json = new JObject(); string personId = "6715f3a1"; if (string.IsNullOrEmpty(personId)) { json.Add(new JProperty("Code", -1)); json.Add(new JProperty("Msg", "参数不正确")); return Content(json.ToString(), "text/json"); } //获得病人信息 var patientData = await homeSV.PatientAsync(personId); JObject j1 = new JObject(); var tempj = JProperty.FromObject(patientData.List); j1.Add(new JProperty("List", tempj.First.First)); j1.Add(new JProperty("Template", patientData.Template)); //获得菜单树信息 var timeAxisData = await homeSV.TimeAxisAllAsync(personId); timeAxisData = new System.Collections.Generic.List<Core.ViewModels.TimeAxisAllViewModel>(); JArray j2 = new JArray(); //获得分类信息 var categoryData = await homeSV.CategoryAsync(personId); JArray j3 = new JArray(); foreach(var q in categoryData) { JObject jobj = new JObject(); var tempj3 = JProperty.FromObject(q.List); jobj.Add(new JProperty("List", tempj3.First.First)); jobj.Add(new JProperty("Template", q.Template)); j3.Add(jobj); } //获得就诊信息 var ctgType = (int)CategoryBizTypeEnum.CheckInInfo; var startIndex = 0; var pageSize = 20; var checkInData = await homeSV.CategoryAsync(ctgType.ToString(), personId, startIndex, pageSize); JObject j4= new JObject(); var tempj4 = JProperty.FromObject(checkInData.List); j4.Add(new JProperty("List", tempj4.First.First)); j4.Add(new JProperty("Template", checkInData.Template)); json.Add(new JProperty("PantData",j1 )); json.Add(new JProperty("TimsData",j2)); json.Add(new JProperty("CaoryData", j3)); json.Add(new JProperty("CckInData", j4)); json.Add(new JProperty("Code", 0)); json.Add(new JProperty("Msg", "请求成功")); return Content(json.ToString(), "text/json"); } return View(); }
已经解决,办法很多。这不知道算是不是最好的?
也可以自己手动去解析 DataSet,按行解析等等。
使用匿名对象