Json.net全局设置

Json.net全局设置

问题描述:

是否可以为Json.net指定全局设置?

Is there a way to specify global settings for Json.net?

我们遇到的问题是将所有DateTimes放入UTC中(正确的做法是).出于遗留目的,我们希望默认为本地时间.我不想到处都放以下代码:

The problem we're having is that it puts all DateTimes in UTC (rightly so). For legacy purposes, we want to default to Local time. I don't want to put the following code all over the place:

var settings = New JsonSerializerSettings();
settings.DateTimeZoneHandling = DateTimeZoneHandling.Local;
JsonConvert.DeserializeObject(json, settings);

因此,它已添加到 查看更多