DataContractJsonSerializer - Deserializing DateTime within List<object>

后端 未结 4 682
情书的邮戳
情书的邮戳 2020-12-01 12:58

I\'m having trouble using the System.Runtime.Serialization.Json.DataContractJsonSerializer class to deserialize DateTime instances contained within a List

4条回答
  •  无人及你
    2020-12-01 13:59

    In the .NET Framework version 4.5 the DataContractJsonSerializer has a constructor that accepts a DataContractJsonSerializerSettings object that can be used to set the DateTimeFormat:

    var ser = new DataContractJsonSerializer(typeof(CreateOmsEntryCommand),
                  new DataContractJsonSerializerSettings
                  {
                      DateTimeFormat = new DateTimeFormat("yyyy-MM-dd'T'HH:mm:ssZ")
                  });
    

提交回复
热议问题