YamlDotNet.System.Text.Json
1.11.0
dotnet add package YamlDotNet.System.Text.Json --version 1.11.0
NuGet\Install-Package YamlDotNet.System.Text.Json -Version 1.11.0
<PackageReference Include="YamlDotNet.System.Text.Json" Version="1.11.0" />
<PackageVersion Include="YamlDotNet.System.Text.Json" Version="1.11.0" />
<PackageReference Include="YamlDotNet.System.Text.Json" />
paket add YamlDotNet.System.Text.Json --version 1.11.0
#r "nuget: YamlDotNet.System.Text.Json, 1.11.0"
#:package YamlDotNet.System.Text.Json@1.11.0
#addin nuget:?package=YamlDotNet.System.Text.Json&version=1.11.0
#tool nuget:?package=YamlDotNet.System.Text.Json&version=1.11.0
YamlDotNet.System.Text.Json
What is this?
This project contains components which allow YamlDotNet to handle System.Text.Json objects and serialize them to YAML and back.
Supported Objects:
System.Text.Json.Serialization.JsonIgnoreAttribute
- Conditions - controls whether a property is included while serializing and deserializing
- Always = Ignore during serialization and deserialization (default)
- Never = Include during serialization and deserialization
- WhenWritingNull = Ignore during serialization when the value is
null - WhenWritingDefault = Ignore during serialization when the value is the type's default value
- WhenWriting = Ignore during serialization
- WhenReading = Ignore during deserialization
Conditional
WhenWritingNullandWhenWritingDefaultproperties remain readable during deserialization. Properties ignored withAlwaysorWhenReadingare treated as known ignored properties and skipped when they appear in YAML input.- Conditions - controls whether a property is included while serializing and deserializing
System.Text.Json.Serialization.JsonPropertyNameAttribute
- Name - Specifies the property name that is present in the JSON/YAML when serializing and deserializing.
System.Text.Json.Serialization.JsonPropertyOrderAttribute
- Order - Sets the serialization order of the property.
System.Text.Json.Serialization.JsonStringEnumMemberNameAttribute
- Name - Sets the value for the Enum Member that is present in the JSON/YAML when serializing and deserializing.
Installation
dotnet add package YamlDotNet.System.Text.Json
YamlConverter
YamlConverter - exposes Serialize() and Deserialize<T>() methods
// to serialize a object to yaml
var yaml = YamlConverter.Serialize(someObject);
// to serialize json to yaml
var yaml = YamlConverter.SerializeJson(someJson);
// to load your object as a typed object
var obj = YamlConverter.Deserialize<MyTypedObject>(yaml);
How to integrate with YamlDotNet
Example:
using YamlDotNet.Serialization;
using YamlDotNet.System.Text.Json;
var serializer = new SerializerBuilder()
.AddSystemTextJson()
.Build();
var yaml = serializer.Serialize(obj);
var deserializer = new DeserializerBuilder()
.AddSystemTextJson()
.Build();
var myObject = deserializer.Deserialize<MyType>(yaml)
Trimming
The library is trim-analyzed. Its default YamlConverter methods and AddSystemTextJson extensions for YamlDotNet's reflection based builders are marked as requiring unreferenced code. For trimmed applications, use the YamlConverter overloads that accept a generated StaticContext, or YamlDotNet's static builders.
Add the Vecc.YamlDotNet.Analyzers.StaticGenerator package to the consuming application, declare a partial StaticContext with [YamlStaticContext] and [YamlSerializable(typeof(MyModel))], then pass that context to YamlConverter.Serialize and YamlConverter.Deserialize<T>. Register all application model types used by the context, including enum types. The AddSystemTextJson builder extensions also support YamlDotNet's static builder types.
The samples project demonstrates static-context serialization and deserialization, JSON property attributes, extension data, ordering and default-value options, unmatched-property handling, and direct static-builder configuration. It also runs as the trimmed consumer smoke test in CI.
For applications configuring YamlDotNet's static builders directly, register each model type and enum in the generated static context. The context must include public model properties, fields, and constructors, and enum public fields for JsonStringEnumMemberNameAttribute. For IDictionary<string, JsonElement> extension data, values may be JSON scalars, dictionaries with string keys, sequences, or existing JsonElement, JsonDocument, or JsonNode instances. Arbitrary CLR objects require runtime JSON metadata and are rejected. IDictionary<string, object> extension data retains its values as objects.
Extension-data properties using a concrete dictionary type other than Dictionary<string, object> or Dictionary<string, JsonElement> should be initialized before deserialization.
Inspired By
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 10.0.12)
- YamlDotNet (>= 18.1.0)
-
net10.0
- YamlDotNet (>= 18.1.0)
-
net11.0
- YamlDotNet (>= 18.1.0)
-
net8.0
- System.Text.Json (>= 10.0.12)
- YamlDotNet (>= 18.1.0)
-
net9.0
- System.Text.Json (>= 10.0.12)
- YamlDotNet (>= 18.1.0)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on YamlDotNet.System.Text.Json:
| Package | Downloads |
|---|---|
|
Devantler.KubernetesGenerator.Core
Package Description |
|
|
DevantlerTech.KubernetesGenerator.Core
Package Description |
|
|
MDAT
Markdown Auto-Tests for .net 6+, based on MSTestsV2 DataSource. |
|
|
PayrollEngine.Client.Core
Payroll Engine Client Core |
|
|
Base.Model
Core models for Response Base |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on YamlDotNet.System.Text.Json:
| Repository | Stars |
|---|---|
|
Azure/apiops
APIOps applies the concepts of GitOps and DevOps to API deployment. By using practices from these two methodologies, APIOps can enable everyone involved in the lifecycle of API design, development, and deployment with self-service and automated tools to ensure the quality of the specifications and APIs that they’re building.
|
|
|
IvanJosipovic/KubeUI
Kubernetes User Interface
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.11.0 | 215 | 9/23/2026 |
| 1.10.0 | 397 | 9/16/2026 |
| 1.9.1 | 4,433 | 7/16/2026 |
| 1.9.0 | 2,220 | 6/14/2026 |
| 1.8.0 | 26,154 | 5/11/2026 |
| 1.7.1 | 42,289 | 11/11/2025 |
| 1.7.0 | 2,097 | 11/10/2025 |
| 1.6.6 | 255,466 | 3/24/2025 |
| 1.6.5 | 30,321 | 12/23/2024 |
| 1.6.4 | 14,566 | 11/13/2024 |
| 1.6.3 | 825 | 11/11/2024 |
| 1.6.2 | 12,156 | 10/9/2024 |
| 1.6.1 | 1,706 | 9/26/2024 |
| 1.6.0 | 1,657 | 9/23/2024 |
| 1.5.1 | 3,821 | 9/23/2024 |
| 1.5.0 | 15,815 | 8/1/2024 |
| 1.4.2 | 41,092 | 7/9/2024 |
| 1.4.1 | 11,312 | 6/27/2024 |
| 1.4.0 | 12,891 | 4/13/2024 |
| 1.3.5 | 1,696 | 2/13/2024 |