The release of .NET Core 3 today includes a brand new serializer for JavaScript Object Notation (JSON) under the System.Text.Json namespace. The Microsoft documentation states,

The System.Text.Json namespace provides high-performance, low-allocating, and standards-compliant capabilities to process JavaScript Object Notation (JSON), which includes serializing objects to JSON text and deserializing JSON text to objects, with UTF-8 support built-in. It also provides types to read and write JSON text encoded as UTF-8, and to create an in-memory document object model (DOM) for random access of the JSON elements within a structured view of the data.
Serialization is used everywhere in programming modern apps for data sent via web-based API’s, used in ASP.NETview models and even for databases like Cosmos DBsince its internal storage is JSON. I even serialize configuration objects to and from disk for apps that I write to store app and user data.
I would say JSON this the most popular way to do serialization due to it being less verbose than XMLand therefore can be more performant. Before .NET Core and even before NuGet, the most widely used library to serialize JSON is Newtonsoft.Jsonwith over 266 million downloads to date!

It’s so popular that even Microsoft uses it, even though .NET and .NET Core (even before version 3) can serialize JSON (via the DataContractJsonSerializer). This free library has a lot of features and is easy to use.
For the remainder of this article, I will show how to use it and show performance data from the second edition (also released today) of my book Rock Your Code: Code & App Performance for Microsoft .NET.



Allan NielsenPosted Dec 11, 2019, 5:28 PM
Sounds awesome, but since you can't use it with EFCore due to navigation property circular references, or deserialization to immutable POCOs (private or internal setters) this library is near useless.