using System.Text.Json; public class Product { public int Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } } class Program { static void Main() { var product = new Product { Id = 1, Name = "Laptop", Price = 1200.99m }; string json = JsonSerializer.Serialize(product); Console.WriteLine(json); } }