My web-api returns an User Object. In that object there is a DateTime property. When i\'am reading it in my Application i get an error because the
Just change the DateTimeFormat on your DataContractJsonSerializer like so:
public static T Deserialize(string json) {
try
{
var settings = new DataContractJsonSerializerSettings
{
DateTimeFormat = new System.Runtime.Serialization.DateTimeFormat("o")
};
var _Bytes = Encoding.Unicode.GetBytes(json);
using (MemoryStream _Stream = new MemoryStream(_Bytes))
{
var _Serializer = new DataContractJsonSerializer(typeof(T), settings);
return (T)_Serializer.ReadObject(_Stream);
}
}
catch (Exception ex)
{
throw ex;
}
}