我有一个包含 DateTime 类型的模型:
public class ToDo
{
public int id { get; set; }
public int parentId { get; set; }
public string note { get; set; }
public DateTime due { get; set; }
public ToDo(int id, int parentId, string note, DateTime due)
{
this.id = id;
this.parentId = parentId;
this.note = note;
this.due = due;
}
}
Run Code Online (Sandbox Code Playgroud)
我为这个类创建了一个控制器来通过 api 发送我的帖子请求。但我不知道如何将 DateTime 类型绑定到 json 我已经尝试了一个具有以下正文的请求,但没有成功:
{"parentId":1,"note":"hello world","due":{"year":2017,"month": 11,"day":25}}
Run Code Online (Sandbox Code Playgroud)
我应该如何发布 DateTime 类型?