I'm attempting to return some JSON from my Nancy application, using the default JSON serializer. I've got the following DTO class:
class Event
{
public DateTimeOffset Timestamp { get; set; }
public string Message { get; set; }
}
When I return it, as follows:
return Response.AsJson(
new Event { Message = "Hello", Timestamp = DateTime.UtcNow });
...I get all of the DateTimeOffset
properties returned, so it looks like this:
"Timestamp": {
"DateTime":"\/Date(1372854863408+0100)\/",
"UtcDateTime":"\/Date(1372858463408)\/",
"LocalDateTime":"\/Date(1372858463408+0100)\/",
"Date":"\/Date(1372806000000+0100)\/",
"Day":3,
"DayOfWeek":3
I was expecting "Timestamp":"\/Date(1372854863408+0100)\/"
, with none of the other stuff. This is the format that Nancy uses for DateTime
values.
How do I configure Nancy to output DateTimeOffset
values in the same style?