C# 在c中从多个数组对象创建单个对象数组#

C# 在c中从多个数组对象创建单个对象数组#,c#,asp.net,C#,Asp.net,我有一个如下所示的web API响应,我需要将所有对象移动到C#ASP.NET中的单个数组中 我想将所有对象移动到单个数组中。如下 [ { "id":23, "name":"John", "email":"John@domain.com", "appointment_date":"tomorrow",

我有一个如下所示的web API响应,我需要将所有对象移动到C#ASP.NET中的单个数组中

我想将所有对象移动到单个数组中。如下

[
   {
      "id":23,
      "name":"John",
      "email":"John@domain.com",
      "appointment_date":"tomorrow",
      "appointment_category":3,
      "time":"morning"
   },
   {
      "id":17,
      "name":"John",
      "email":"John@domain.com",
      "appointment_date":"tomorrow",
      "appointment_category":3,
      "time":"morning"
   },
   {
      "id":17,
      "name":"John",
      "email":"John@domain.com",
      "appointment_date":"tomorrow",
      "appointment_category":3,
      "time":"morning"
   }
]

请帮我谢谢你,我不确定你是否已经反序列化了json。但你可以这样做。创建2个类并使用Newtonsoft.Json反序列化。然后使用
Linq
SelectMany
获得单个对象的列表

//deseralize the json
var list1 = JsonConvert.DeserializeObject<List<List<Class2>>>(json);

//select all the nested items
var list2 = list1.SelectMany(x => x).ToList();
//反序列化json
var list1=JsonConvert.DeserializeObject(json);
//选择所有嵌套项
var list2=list1.SelectMany(x=>x.ToList();
班级

public class Class1
{
    public List<Class1> list { get; set; }
}


public class Class2
{
    public int id { get; set; }
    public string name { get; set; }
    public string email { get; set; }
}
公共类1
{
公共列表{get;set;}
}
公共课2
{
公共int id{get;set;}
公共字符串名称{get;set;}
公共字符串电子邮件{get;set;}
}

结果。选择many(x=>x)。ToArray()
感谢您的响应。不创建类是不可能的。实际上,我正在将响应动态添加到列表(列表数据=新列表)并最终返回数据。不,不是真的。如果没有类,则必须操作json字符串本身。很快就会变得一团糟。
public class Class1
{
    public List<Class1> list { get; set; }
}


public class Class2
{
    public int id { get; set; }
    public string name { get; set; }
    public string email { get; set; }
}