using Newtonsoft.Json; class Program { static void Main() { var json = JsonConvert.SerializeObject(new { Name = "Ali", Age = 30 }); Console.WriteLine(json); } }