• <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 格式化程序?

        JSON formatter in C#?(C# 中的 JSON 格式化程序?)
            <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 格式化程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Force JsonConvert.SerializeXmlNode to serialize node value as an Integer or a Boolean(强制 JsonConvert.SerializeXmlNode 将节点值序列化为整数或布尔值)
                  Using JSON to Serialize/Deserialize TimeSpan(使用 JSON 序列化/反序列化 TimeSpan)
                  Could not determine JSON object type for type quot;Classquot;(无法确定类型“Class的 JSON 对象类型.)
                  How to deserialize a JSONP response (preferably with JsonTextReader and not a string)?(如何反序列化 JSONP 响应(最好使用 JsonTextReader 而不是字符串)?)
                  how to de-serialize JSON data in which Timestamp it-self contains fields?(如何反序列化时间戳本身包含字段的JSON数据?)
                  JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)
                  <legend id='vFxu4'><style id='vFxu4'><dir id='vFxu4'><q id='vFxu4'></q></dir></style></legend>

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

                          • <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>