public static void Main()
Console.WriteLine("Testing System.Text.Json Serializer ...\n");
Console.WriteLine("\n=============================\n");
Console.WriteLine("Testing Newtonsoft.JSON ...\n");
TestNewtonsoftJsonSerializer();
public static void TestCoreSerializer()
var customer = new Customer {FirstName = "Jon", LastName = "Jones", IsItSafe = false};
Console.WriteLine("Serializing...");
var serialized = System.Text.Json.JsonSerializer.Serialize(customer);
Console.WriteLine(serialized);
Console.WriteLine("\nDeserializing...");
var deserialized = System.Text.Json.JsonSerializer.Deserialize<Customer>(serialized);
Console.WriteLine(deserialized.FirstName + " is the first name.");
public static void TestNewtonsoftJsonSerializer()
var customer = new Customer {FirstName = "Jon", LastName = "Jones", IsItSafe = false};
Console.WriteLine("Serializing...");
var serialized = Newtonsoft.Json.JsonConvert.SerializeObject(customer);
Console.WriteLine(serialized);
Console.WriteLine("\nDeserializing...");
var deserialized =Newtonsoft.Json.JsonConvert.DeserializeObject<Customer>(serialized);
Console.WriteLine(deserialized.FirstName + " is the first name.");
public string FirstName {get; set;}
public string LastName {get; set;}
public bool IsItSafe {get; set;}