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

        <tfoot id='FsNyM'></tfoot>
        <legend id='FsNyM'><style id='FsNyM'><dir id='FsNyM'><q id='FsNyM'></q></dir></style></legend>

        <small id='FsNyM'></small><noframes id='FsNyM'>

        使用 Json.net 编写 JSON 时如何打开缩进?

        时间:2023-08-23
        <tfoot id='KY417'></tfoot>

        <small id='KY417'></small><noframes id='KY417'>

          <tbody id='KY417'></tbody>

          • <bdo id='KY417'></bdo><ul id='KY417'></ul>
              <legend id='KY417'><style id='KY417'><dir id='KY417'><q id='KY417'></q></dir></style></legend>

                • <i id='KY417'><tr id='KY417'><dt id='KY417'><q id='KY417'><span id='KY417'><b id='KY417'><form id='KY417'><ins id='KY417'></ins><ul id='KY417'></ul><sub id='KY417'></sub></form><legend id='KY417'></legend><bdo id='KY417'><pre id='KY417'><center id='KY417'></center></pre></bdo></b><th id='KY417'></th></span></q></dt></tr></i><div id='KY417'><tfoot id='KY417'></tfoot><dl id='KY417'><fieldset id='KY417'></fieldset></dl></div>
                  本文介绍了使用 Json.net 编写 JSON 时如何打开缩进?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 Json.Net 将 XML 序列化为 Json .当我将序列化的字符串写入文件时,它都在一行中.我如何让它看起来像 Json 并带有通常的制表符和缩进?

                  I am using Json.Net to serialize XML into Json . When i write the serialized string to a file it all comes in a single line . How do i get it to actually look like Json with the usual tabs and indentation?

                  推荐答案

                  设置 JSON 编写器 Formatting 属性到 Formatting.Indented:

                  Set the JSON writer Formatting property to Formatting.Indented:

                  jsonWriter.Formatting = Formatting.Indented;
                  

                  JsonConvert.Serialize* 方法还具有采用 Formatting 枚举的重载(感谢 John Flatness).

                  The JsonConvert.Serialize* methods also have overloads that take a Formatting enum (thanks John Flatness).

                  文档:序列化对象

                  这篇关于使用 Json.net 编写 JSON 时如何打开缩进?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:无法使用 Json.NET 将枚举正确转换为 json 下一篇:如何使用 NewtonSoft 更新 JSON 对象的属性

                  相关文章

                  最新文章

                  <tfoot id='oAwMz'></tfoot>
                • <legend id='oAwMz'><style id='oAwMz'><dir id='oAwMz'><q id='oAwMz'></q></dir></style></legend>

                        <bdo id='oAwMz'></bdo><ul id='oAwMz'></ul>

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