I have a object that I serialize with the JavaScriptSerializer and output it in a javascript variable.
A property on this object is a date which gets converted to eg. "/Date(1309498021672)/"
I then send this value to the server via a ui wcf service call. I want to deserialize this value in to a DateTime object.
How can I do t开发者_如何学编程his? I am working with asp.net c# web application.
Your string format is just a little off, but this will deserialize to a proper date.
var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
string json = "\"\\/Date(1309498021672)\\/\"";
DateTime date = serializer.Deserialize<DateTime>(json);
// date is 7/1/2011 5:27:01 AM
精彩评论