ASP.NET MVC Json序列化时区差解决方法

ASP.NET MVC的controller方法json()序列化对象时,会将datetime属性值序列化为相应的UTC时间,

如果使用Newtonsoft.Json直接反序列化则得到的时间值会少8小时,可通过设置反序列化设置时区为本地时区解决,如下:

JsonConvert.DeserializeObject<T>(jsonStr, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Local });

博客备忘,一起成长。
原文地址:https://www.cnblogs.com/lumingprince/p/15064408.html