c#将json串转换成数组

xiaoxiao2021-02-28  21

引用

using Newtonsoft.Json.Linq; using Newtonsoft.Json;

程序

string jsonText = "{'Total':'0','Rows':[{'id':'31','project':'6','project_name':'一卡通','name':'接口测试!','assignedTo':'zhangsan'," +"'realname':'张三','estStarted':'2016/11/23','realStarted':'2000/01/01','status':'wait'}," + "{'id':'32','project':'6','project_name':'一卡通','name':'测试服务器调通!','assignedTo':'lisi'," +"'realname':'李四','estStarted':'2016/11/23','realStarted':'2016/11/23','status':'wait'}]}"; JObject json1 = (JObject)JsonConvert.DeserializeObject(jsonText); JArray array = (JArray)json1["Rows"]; int i = array.Count; string aa=""; foreach (var jObject in array) { //赋值属性 aa = jObject["id"].ToString();//获取字符串中id值 }             }

转载请注明原文地址: https://www.6miu.com/read-2250284.html

最新回复(0)