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
- 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
- Preserve references
- Immutable types and non-public accessors
- Polymorphic serialization
- Migrate from Newtonsoft.Json to System.Text.Json
- Customize character encoding
- Use the JSON DOM, Utf8JsonReader, and Utf8JsonWriter
- Write custom converters for JSON serialization
- DateTime and DateTimeOffset support
- Supported collection types in System.Text.Json
- System.Text.Json API reference
- System.Text.Json.Serialization API reference