c# format json
var json = JsonSerializer.Serialize(object, new JsonSerializerOptions{WriteIndented = true});
c# format json
var json = JsonSerializer.Serialize(object, new JsonSerializerOptions{WriteIndented = true});
c# format json
using Newtonsoft.Json;
private static string FormatPrettyJson(object myobject)
{
string json = JsonConvert.SerializeObject(object, Formatting.Indented);
return json;
}
c# beautify json string
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);
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us