Difficulty with Conversion of Date Time to JSON data

I am trying to convert a list<T> into JSON data and then binding to Jqgrid.

The Problem is that list collection contains one of the column as DateTime.

When i see the resultant JSON response, the date time is not properly serialized. Its coming like this:

 /Date(1267408935000)/

How to convert list collection into JSON data properly when it contains date time columns.

Please help..

Jon Skeet
people
quotationmark

When you say it's "not properly serialized" - that looks okay to me. That's one format for JSON dates, coming from the Javascript Date constructor taking a "milliseconds since the Unix epoch" as a parameter. So the value you've given is March 1st 2010 02:02:15 UTC for example.

I'd expect the Javascript deserializing this data to be absolutely fine - but of course that's not necessarily the case... If it's really causing problems for you, read Scott Hanselman's blog post about JSON date/time formats - in particular, it explains how you can swap out the JSON formatter to be Json.NET, which uses an ISO-8601 format by default.

people

See more on this question at Stackoverflow