JSON DATA formatting in WebAPI
Posted
by
user1736299
on Stack Overflow
See other posts from Stack Overflow
or by user1736299
Published on 2012-12-05T23:01:18Z
Indexed on
2012/12/05
23:03 UTC
Read the original article
Hit count: 242
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
© Stack Overflow or respective owner