Proper Way to Convert JSON Date to .NET DateTime During Deserialization

前端 未结 6 1281
暖寄归人
暖寄归人 2020-12-06 01:12

I have a javascript function that calls an MVC controller with JSON data:

var specsAsJson = JSON.stringify(specs);
$.post(\'/Home/Save\', { jsonData: specsAs         


        
6条回答
  •  旧时难觅i
    2020-12-06 01:55

    JavaScript (well, EcmaScript) defines its DateTime string interchange format based on a simplification of the ISO-8601 standard.

    XML Schema defines its DateTime string interchange format based on ISO-8601 also.

    I have found it handy to use the .NET class System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDateTime to handle conversion from .NET DateTime values to XML formats and back.

    Since JavaScript is based on the same ISO-8601 standard, perhaps it will work for your JSON case as well.

提交回复
热议问题