.NET JsonSerializer is over 200x faster if you reuse JsonSerializerOptions

When you serialize an object using the built-in .NET JsonSerializer (System.Text.Json), reusing the JsonSerializerOptions object is 200x faster than serializing with a new options object each time. The JsonSerializerOptions object must have some kind of internal caching mechanism that makes subsequent serializations on the same type significantly faster. Note: Creating the new JsonSerializerOptions object adds … Read more .NET JsonSerializer is over 200x faster if you reuse JsonSerializerOptions

C# – How to copy an object

In this article I’ll explain how to copy an object. First I’ll explain the difference between shallow and deep copying. Then I’ll show how to shallow copy and four different ways to deep copy – including manually copying and using serialization. Finally I’ll show a speed and feature comparison of each approach, and a decision … Read more C# – How to copy an object