showing results for - "c 23 beautify json string"
Emanuele
16 Feb 2018
1public class Product
2{
3    public string Name {get; set;}
4    public DateTime Expiry {get; set;}
5    public string[] Sizes {get; set;}
6}
7
8public void Main()
9{
10    Product product = new Product();
11    product.Name = "Apple";
12    product.Expiry = new DateTime(2008, 12, 28);
13    product.Sizes = new string[] { "Small" };
14
15    string json = JsonConvert.SerializeObject(product, Formatting.None);
16    Console.WriteLine(json);
17    json = JsonConvert.SerializeObject(product, Formatting.Indented);
18    Console.WriteLine(json);
19}