public class CalendarController : ApiController
{
Events[] events = new Events[]
{
new Events { title= "event1", start = System.DateTime.UtcNow, end = System.DateTime.UtcNow },
new Events { title= "event2", start = System.DateTime.UtcNow, end = System.DateTime.UtcNow },
new Events { title= "event3", start = System.DateTime.UtcNow, end = System.DateTime.UtcNow}
};
public IEnumerable<Events> GetAllCalendar()
{
return events;
}
上面的 JSON 结果是
[{
"title": "event1",
"start": "2012-12-05T22:52:35.6471712Z",
"end": "2012-12-05T22:52:35.6471712Z"
},{
"title": "event2",
"start": "2012-12-05T22:52:35.6471712Z",
"end": "2012-12-05T22:52:35.6471712Z"
},{
"title": "event3",
"start": "2012-12-05T22:52:35.6471712Z",
"end": "2012-12-05T22:52:35.6471712Z"
}]
- 如何在没有双引号但单引号的情况下创建相同的 JSON 结果。
- 如何以 'YYYY-MM-DD HH:MM:SS' 格式获取日期 谢谢你,史密斯