1. <small id='WDkAY'></small><noframes id='WDkAY'>

        <bdo id='WDkAY'></bdo><ul id='WDkAY'></ul>
      <legend id='WDkAY'><style id='WDkAY'><dir id='WDkAY'><q id='WDkAY'></q></dir></style></legend>
      <i id='WDkAY'><tr id='WDkAY'><dt id='WDkAY'><q id='WDkAY'><span id='WDkAY'><b id='WDkAY'><form id='WDkAY'><ins id='WDkAY'></ins><ul id='WDkAY'></ul><sub id='WDkAY'></sub></form><legend id='WDkAY'></legend><bdo id='WDkAY'><pre id='WDkAY'><center id='WDkAY'></center></pre></bdo></b><th id='WDkAY'></th></span></q></dt></tr></i><div id='WDkAY'><tfoot id='WDkAY'></tfoot><dl id='WDkAY'><fieldset id='WDkAY'></fieldset></dl></div>

        <tfoot id='WDkAY'></tfoot>

        设置默认全局 json 序列化程序设置

        时间:2023-08-24
      1. <i id='GWkPZ'><tr id='GWkPZ'><dt id='GWkPZ'><q id='GWkPZ'><span id='GWkPZ'><b id='GWkPZ'><form id='GWkPZ'><ins id='GWkPZ'></ins><ul id='GWkPZ'></ul><sub id='GWkPZ'></sub></form><legend id='GWkPZ'></legend><bdo id='GWkPZ'><pre id='GWkPZ'><center id='GWkPZ'></center></pre></bdo></b><th id='GWkPZ'></th></span></q></dt></tr></i><div id='GWkPZ'><tfoot id='GWkPZ'></tfoot><dl id='GWkPZ'><fieldset id='GWkPZ'></fieldset></dl></div>
          <tbody id='GWkPZ'></tbody>
          <bdo id='GWkPZ'></bdo><ul id='GWkPZ'></ul>
        • <small id='GWkPZ'></small><noframes id='GWkPZ'>

            <legend id='GWkPZ'><style id='GWkPZ'><dir id='GWkPZ'><q id='GWkPZ'></q></dir></style></legend>

              <tfoot id='GWkPZ'></tfoot>

                  本文介绍了设置默认全局 json 序列化程序设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试在我的 global.asax 中设置像这样的全局序列化程序设置.

                  I'm trying to set the global serializer settings like this in my global.asax.

                  var formatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
                  formatter.SerializerSettings = new JsonSerializerSettings
                  {
                      Formatting = Formatting.Indented,
                      TypeNameHandling = TypeNameHandling.Objects,
                      ContractResolver = new CamelCasePropertyNamesContractResolver()
                  };
                  

                  使用以下代码序列化对象时,不使用全局序列化器设置?

                  When serializing object using the following code the global serializer settings are not used?

                  return new HttpResponseMessage(HttpStatusCode.OK)
                  {
                      Content = new StringContent(JsonConvert.SerializeObject(page))
                  };
                  

                  不能像这样设置全局序列化程序设置还是我遗漏了什么?

                  Isn't it possible to set the global serializer settings like this or am I missing something?

                  推荐答案

                  设置 JsonConvert.DefaultSettings 成功了.

                  JsonConvert.DefaultSettings = () => new JsonSerializerSettings
                  {
                      Formatting = Formatting.Indented,
                      TypeNameHandling = TypeNameHandling.Objects,
                      ContractResolver = new CamelCasePropertyNamesContractResolver()
                  };
                  

                  这篇关于设置默认全局 json 序列化程序设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:什么是 XML 的 XPath、SelectNodes、SelectSingleNode 的 下一篇:阅读完 JSON 内容后遇到的附加文本:

                  相关文章

                  最新文章

                    <i id='rfTuc'><tr id='rfTuc'><dt id='rfTuc'><q id='rfTuc'><span id='rfTuc'><b id='rfTuc'><form id='rfTuc'><ins id='rfTuc'></ins><ul id='rfTuc'></ul><sub id='rfTuc'></sub></form><legend id='rfTuc'></legend><bdo id='rfTuc'><pre id='rfTuc'><center id='rfTuc'></center></pre></bdo></b><th id='rfTuc'></th></span></q></dt></tr></i><div id='rfTuc'><tfoot id='rfTuc'></tfoot><dl id='rfTuc'><fieldset id='rfTuc'></fieldset></dl></div>
                  1. <small id='rfTuc'></small><noframes id='rfTuc'>

                      <tfoot id='rfTuc'></tfoot>
                        <bdo id='rfTuc'></bdo><ul id='rfTuc'></ul>

                      <legend id='rfTuc'><style id='rfTuc'><dir id='rfTuc'><q id='rfTuc'></q></dir></style></legend>