C#格式化JSON字符串


注意:需添加引用库文件Newtonsoft.Json.dll,并using Newtonsoft.Json;

 

 1         public static string FormatJsonStr(string sourJsonStr)
 2         {
 3             //格式化json字符串
 4             dynamic objx = JsonConvert.DeserializeObject(sourJsonStr);
 5             return FormatJsonString(objx);
 6         }
 7 
 8         public static string FormatJsonString(object obj)
 9         {
10             return JsonConvert.SerializeObject(obj, Formatting.Indented);
11         }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM