JSON serialization and deserialization (marshalling and unmarshalling) in .NET - overview
The library design emphasizes high performance and low memory allocation over an extensive feature set. Built-in UTF-8 support optimizes the process of reading and writing JSON text encoded as UTF-8, which is the most prevalent encoding for data on the web and files on disk.
The library also provides classes for working with an in-memory document object model (DOM). This feature enables random read-only access of the elements in a JSON file or string.
There are some limitations on what parts of the library that you can use from Visual Basic code. For more information, see Visual Basic support.
How to get the library
The library is built-in as part of the shared framework for .NET Core 3.0 and later versions.
For earlier framework versions, install the System.Text.Json NuGet package. The package supports:
- .NET Standard 2.0 and later versions
- .NET Framework 4.7.2 and later versions
- .NET Core 2.0, 2.1, and 2.2
System.Text.Jsontypes are thread-safe, including:
- How to use the library
- Instantiate JsonSerializerOptions instances
- Enable case-insensitive matching
- Customize property names and values
- Ignore properties
- Allow invalid JSON
- Handle overflow JSON or use JsonElement or JsonNode
- Preserve references and handle circular references
- Deserialize to immutable types and non-public accessors
- Polymorphic serialization
- Migrate from Newtonsoft.Json to System.Text.Json
- Customize character encoding
- Use DOM, Utf8JsonReader, and Utf8JsonWriter
- Write custom converters for JSON serialization
- DateTime and DateTimeOffset support
- How to use source generation
- Supported collection types
- System.Text.Json API reference
- System.Text.Json.Serialization API reference