using System.Text.Json; static void TextJsonDemo() { var obj = new { Id = 1, Name = "Fred", Age = 33, Org = new[] { new { Id=1, Name="MS" }, new { Id=2, Name="SMF" }, new { Id=3, Name="Agile" } } }; string jsonValue = JsonSerializer.Serialize(obj); Console.WriteLine(jsonValue); }