Asp.net mvc 职位列表<;模型>;到MVC web api 2

Asp.net mvc 职位列表<;模型>;到MVC web api 2,asp.net-mvc,asp.net-web-api,asp.net-web-api2,Asp.net Mvc,Asp.net Web Api,Asp.net Web Api2,我试图POST到List但是模型总是空的(null) ApiController: [HttpPost] public void AddShop(List<Shop> shop) { } public class Shop { public string Name { get; set; } public string Email { get; set; } } [HttpPost] public void AddShop(Shop shop) { } {

我试图
POST
List
但是模型总是空的(
null

ApiController:

[HttpPost]
public void AddShop(List<Shop> shop)
{

}
public class Shop 
{
 public string Name { get; set; }
 public string Email { get; set; }
}
[HttpPost]
public void AddShop(Shop shop)
{

}
{
     "Name"  : "Shop1", 
     "Email" : "shop1@email.com"    
  }
我以
Json
的身份与邮递员一起发布:

    {
      {
       "Name"  : "Shop1", 
       "Email" : "shop1@email.com"    
       },
       {
       "Name"  : "Shop2", 
       "Email" : "shop2@email.com"    
       }    
    }
当我发布到同一型号但不是作为
列表发布时
已成功绑定:

ApiController:

[HttpPost]
public void AddShop(List<Shop> shop)
{

}
public class Shop 
{
 public string Name { get; set; }
 public string Email { get; set; }
}
[HttpPost]
public void AddShop(Shop shop)
{

}
{
     "Name"  : "Shop1", 
     "Email" : "shop1@email.com"    
  }
邮递员:

[HttpPost]
public void AddShop(List<Shop> shop)
{

}
public class Shop 
{
 public string Name { get; set; }
 public string Email { get; set; }
}
[HttpPost]
public void AddShop(Shop shop)
{

}
{
     "Name"  : "Shop1", 
     "Email" : "shop1@email.com"    
  }

那么,在您的情况下,它应该是数组,您的Json应该如下所示:

[
   {
     "Name"  : "Shop1", 
     "Email" : "shop1@email.com"    
   },
   {
     "Name"  : "Shop2", 
     "Email" : "shop2@email.com"    
   }    
]
现在,您可以发布和
对象
而不是
数组

您能否演示如何将对象序列化为
json
?也许有一个更容易的方法