实体类:
public class Sim2Model { public int uid { get; set; } public string password { get; set; } public int templateId { get; set; } public string extend { get; set; } public string customId { get; set; } public string time { get; set; } public SimObj[] _params { get; set; } } public class SimObj { public string mobile { get; set; } public string[] param { get; set; } }
请求示例: { "uid": 123456, "password": "d26a2abe1c51f401b37a14e400d33624f", "templateId": 12365, "extend": "86985", "customId": "121", "time":"2020-01-03 08:08:08", "params": [{ "mobile": "15236521425", "param": ["tom", "上海"] }, { "mobile": "15298741547", "param": ["cat", "北京"] } ] }
文本框中可能输入多个手机号用逗号分开,按照请求示例要求,params应该是个数组,根据这个结构应该怎么传值呢,有点懵
public class Sim2Model
{
public int uid { get; set; }
public string password { get; set; }
public int templateId { get; set; }
public string extend { get; set; }
public string customId { get; set; }
public string time { get; set; }
public SimObj[] _params { get; set; }
}
public class SimObj
{
public string mobile { get; set; }
public string[] param { get; set; }
}
在Controller层,可以这样接收json参数,
/// <summary>
/// 创建Sim2Model
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost()]
[ProducesResponseType(typeof(ResponseInfo<bool>), 200)]
public async Task<IActionResult> CreateChannel(Sim2Model model)
{
//ToDo
}
推荐一个实战教程 《.NET Core 跨平台实战(附源码)》