//cs json 同时包含项JObject和数组JArray的处理
string jsonText = @"{
""项目编号"": ""GPON-1"",
""试验项目"": [{
""试验项目"": ""WIFI"",
""试验标准或条件"": ""GBxxxx-001"",
""实验室"": ""性能测试室""
},
{
""试验项目"": ""高温"",
""试验标准或条件"": ""GBxxxx-002"",
""实验室"": ""环境测试室""
}],
""完成时间"": ""2022-4-27 11:20:16.325""
}";
Newtonsoft.Json.Linq.JObject jObj = Newtonsoft.Json.Linq.JObject.Parse(jsonText);
Newtonsoft.Json.Linq.JArray jarray = Newtonsoft.Json.Linq.JArray.Parse(jObj["试验项目"].ToString());
string items = "";
foreach (var item in jarray)
{
items += item["试验项目"] + "," + item["试验标准或条件"] + "," + item["实验室"] + ";";
}
Label1.Text ="项目编号:"+ jObj["项目编号"].ToString()+ "<br />试验项目:" + items;
//项目编号:GPON-1
//试验项目:WIFI,GBxxxx-001,性能测试室;高温,GBxxxx-002,环境测试室;