• <bdo id='BAPDz'></bdo><ul id='BAPDz'></ul>
      1. <small id='BAPDz'></small><noframes id='BAPDz'>

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

        C# 中的 JSON 格式化程序?

        时间:2023-05-20
            <bdo id='zdsrO'></bdo><ul id='zdsrO'></ul>

              <legend id='zdsrO'><style id='zdsrO'><dir id='zdsrO'><q id='zdsrO'></q></dir></style></legend>
              • <small id='zdsrO'></small><noframes id='zdsrO'>

                  <tbody id='zdsrO'></tbody>
                <tfoot id='zdsrO'></tfoot>

                • <i id='zdsrO'><tr id='zdsrO'><dt id='zdsrO'><q id='zdsrO'><span id='zdsrO'><b id='zdsrO'><form id='zdsrO'><ins id='zdsrO'></ins><ul id='zdsrO'></ul><sub id='zdsrO'></sub></form><legend id='zdsrO'></legend><bdo id='zdsrO'><pre id='zdsrO'><center id='zdsrO'></center></pre></bdo></b><th id='zdsrO'></th></span></q></dt></tr></i><div id='zdsrO'><tfoot id='zdsrO'></tfoot><dl id='zdsrO'><fieldset id='zdsrO'></fieldset></dl></div>
                  本文介绍了C# 中的 JSON 格式化程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  寻找一个函数,该函数将 Json 的 string 作为输入,并使用换行符和缩进对其进行格式化.验证将是一个奖励,但不是必需的,我不需要将其解析为对象或任何东西.

                  Looking for a function that will take a string of Json as input and format it with line breaks and indentations. Validation would be a bonus, but isn't necessary, and I don't need to parse it into an object or anything.

                  有人知道这样的图书馆吗?

                  Anyone know of such a library?

                  示例输入:

                  {"status":"OK", "results":[ {"types":[ "locality", "political"], "formatted_address":"New York, NY, USA", "address_components":[ {"long_name":"New York", "short_name":"New York", "types":[ "locality", "political"]}, {"long_name":"New York", "short_name":"New York", "types":[ "administrative_area_level_2", "political"]}, {"long_name":"New York", "short_name":"NY", "types":[ "administrative_area_level_1", "political"]}, {"long_name":"United States", "short_name":"US", "types":[ "country", "political"]}], "geometry":{"location":{"lat":40.7143528, "lng":-74.0059731}, "location_type":"APPROXIMATE", "viewport":{"southwest":{"lat":40.5788964, "lng":-74.2620919}, "northeast":{"lat":40.8495342, "lng":-73.7498543}}, "bounds":{"southwest":{"lat":40.4773990, "lng":-74.2590900}, "northeast":{"lat":40.9175770, "lng":-73.7002720}}}}]} 
                  

                  推荐答案

                  这对我在 .Net Core 3.1 中使用 System.Text.Json 有效

                  This worked for me using System.Text.Json in .Net Core 3.1

                   public string PrettyJson(string unPrettyJson)
                   {
                       var options = new JsonSerializerOptions(){
                           WriteIndented = true
                       };
                  
                       var jsonElement = JsonSerializer.Deserialize<JsonElement>(unPrettyJson);
                  
                       return JsonSerializer.Serialize(jsonElement, options);
                   }
                  

                  这篇关于C# 中的 JSON 格式化程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:自定义数字格式字符串以始终显示符号 下一篇:格式数字,如堆栈溢出(以 K 后缀四舍五入到千位)

                  相关文章

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

                  • <bdo id='vFxu4'></bdo><ul id='vFxu4'></ul>
                  <tfoot id='vFxu4'></tfoot>

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

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