JSON DATA formatting in WebAPI
- by user1736299
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;
}
The JSON result for the above is
[{
"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"
}]?
How to create the same JSON result without the double quotes but single quote.
How to get the date in the format of ‘YYYY-MM-DD HH:MM:SS’
Thank you,
Smith