为什么ServiceStack.Text不会默认日期以ISO8601?日期、ServiceStack、Text

2023-09-04 02:32:52 作者:像雾像雨又像风

如果我用Newtonsoft.Json.NET则默认为ISO8601(例如: 2011-06-02T09:34:29 + 02:00 )的序列化/反序列化日期

If I use Newtonsoft.Json.NET it defaults to iso8601 (i.e.: 2011-06-02T09:34:29+02:00) for serializing/deserializing dates.

为什么ServiceStack.Text不默认为此,我需要将其指定为配置设置?

Why ServiceStack.Text doesn't default to this and I need to specify it as a configuration setting?

推荐答案

ServiceStack跟着.NET DataContractSerailizer默认值,不能JSON.NET。我们都不愿意作出这样重大更改,尤其是当有一个简单的方法,它以其他方式配置:

ServiceStack followed the .NET DataContractSerailizer defaults, not JSON.NET. We are reluctant to make breaking changes like this, especially when there's an easy way to configure it otherwise with:

JsConfig.DateHandler = DateHandler.ISO8601;