I have a bunch of entity class (generated by Linq to SQL) with a few DateTimeOffset properties in it.
When I send that over the wire as JSON from a .asmx web service, the JSON serializer generates the following JSON:
{"DateTime":"\/Date(1252142834307)\/",
"UtcDateTime":"\/Date(1252142834307)\/",
"LocalDateTime":"\/Date(1252142834307)\/",
"Date":"\/Date(1252101600000)\/",
"Day":5,
"DayOfWeek":6,
"DayOfYear":248,
"Hour":11,
"Millisecond":307,
"Minute":27,
"Month":9,
"Offset":{"Ticks":72000000000,
"Days":0,
"Hours":2,
"Milliseconds":0,
"Minutes":0,
"Seconds":0,
"TotalDays":0.083333333333333329,
"TotalHours":2,
"TotalMilliseconds":7200000,
"TotalMinutes":120,
"TotalSeconds":7200},
"Second":14,
"Ticks":633877468343070254,
"UtcTicks":633877396343070254,
"TimeOfDay":{"Ticks":412343070254,
"Days":0,
"Hours":11,
"Milliseconds":307,
"Minutes":27,
"Seconds":14,
"TotalDays":0.47724892390509255,
"TotalHours":11.453974173722221,
"TotalMilliseconds":41234307.025400005,
"TotalMinutes":687.23845042333335,
"TotalSeconds":41234.3070254},
"Year":2009}
}
I would very much like to save the bandwidth and JSON parsing time the client. I would also really like to avoid having to project every single DateTimeOffset manually before sending it off to the web service.
I realize the JSON serializer do as it is suppose to, so my question is this: Is there a way to configure the JSON serializer so that it just sends the LocalDateTime property of the DateTimeOffset object?
Thanks, Egil.