美文网首页
Csharp Beautify Json String

Csharp Beautify Json String

作者: 大地缸 | 来源:发表于2021-01-30 07:26 被阅读0次

    title: "Csharp Beautify Json String"
    date: 2021-01-27T21:55:17+08:00
    draft: true
    tags: ['csharp','json']
    author: "dadigang"
    author_cn: "大地缸"
    personal: "http://www.real007.cn"


    关于作者

    http://www.real007.cn/about

    public class Product
    {
        public string Name {get; set;}
        public DateTime Expiry {get; set;}
        public string[] Sizes {get; set;}
    }
    
    public void Main()
    {
        Product product = new Product();
        product.Name = "Apple";
        product.Expiry = new DateTime(2008, 12, 28);
        product.Sizes = new string[] { "Small" };
    
        string json = JsonConvert.SerializeObject(product, Formatting.None);
        Console.WriteLine(json);
        json = JsonConvert.SerializeObject(product, Formatting.Indented);
        Console.WriteLine(json);
    }
    

    相关文章

      网友评论

          本文标题:Csharp Beautify Json String

          本文链接:https://www.haomeiwen.com/subject/jezxtltx.html