Json.net全局设置 [英] Json.net global settings

查看:63
本文介绍了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);

推荐答案

因此,它已添加到 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆