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"
}]
答案 0 :(得分:0)
答案 1 :(得分:0)
到目前为止,在C#中处理JSON的最简单方法是使用优秀的JSON.net库:
http://james.newtonking.com/pages/json-net.aspx
此外,使用以下优秀的网站,它将获取您的JSON并创建相关的C#类: