YamlDotNet 16.1.3
YamlDotNet
Appveyor | NuGet |
---|---|
YamlDotNet is a YAML library for netstandard and other .NET runtimes.
YamlDotNet provides low level parsing and emitting of YAML as well as a high level object model similar to XmlDocument. A serialization library is also included that allows to read and write objects from and to YAML streams.
YamlDotNet's conformance with YAML specifications:
YAML Spec | YDN Parser | YDN Emitter |
---|---|---|
v1.1 | ✓ | ✓ |
v1.2 | ✓ |
What is YAML?
YAML, which stands for "YAML Ain't Markup Language", is described as "a human friendly data serialization standard for all programming languages". Like XML, it allows to represent about any kind of data in a portable, platform-independent format. Unlike XML, it is "human friendly", which means that it is easy for a human to read or produce a valid YAML document.
The YamlDotNet library
The library has now been successfully used in multiple projects and is considered fairly stable. It is compatible with the following runtimes:
- netstandard 2.0
- netstandard 2.1
- .NET 6.0
- .NET 8.0
- .NET Framework 4.7
Quick start
Here are some quick samples to get you started which can be viewed in this fiddle.
Serialization from an object to a string
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
...
var person = new Person
{
Name = "Abe Lincoln",
Age = 25,
HeightInInches = 6f + 4f / 12f,
Addresses = new Dictionary<string, Address>{
{ "home", new Address() {
Street = "2720 Sundown Lane",
City = "Kentucketsville",
State = "Calousiyorkida",
Zip = "99978",
}},
{ "work", new Address() {
Street = "1600 Pennsylvania Avenue NW",
City = "Washington",
State = "District of Columbia",
Zip = "20500",
}},
}
};
var serializer = new SerializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.Build();
var yaml = serializer.Serialize(person);
System.Console.WriteLine(yaml);
// Output:
// name: Abe Lincoln
// age: 25
// heightInInches: 6.3333334922790527
// addresses:
// home:
// street: 2720 Sundown Lane
// city: Kentucketsville
// state: Calousiyorkida
// zip: 99978
// work:
// street: 1600 Pennsylvania Avenue NW
// city: Washington
// state: District of Columbia
// zip: 20500
Deserialization from a string to an object
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
...
var yml = @"
name: George Washington
age: 89
height_in_inches: 5.75
addresses:
home:
street: 400 Mockingbird Lane
city: Louaryland
state: Hawidaho
zip: 99970
";
var deserializer = new DeserializerBuilder()
.WithNamingConvention(UnderscoredNamingConvention.Instance) // see height_in_inches in sample yml
.Build();
//yml contains a string containing your YAML
var p = deserializer.Deserialize<Person>(yml);
var h = p.Addresses["home"];
System.Console.WriteLine($"{p.Name} is {p.Age} years old and lives at {h.Street} in {h.City}, {h.State}.");
// Output:
// George Washington is 89 years old and lives at 400 Mockingbird Lane in Louaryland, Hawidaho.
More information
More information can be found in the project's wiki.
Installing
Just install the YamlDotNet NuGet package:
PM> Install-Package YamlDotNet
If you do not want to use NuGet, you can download binaries here.
YamlDotNet is also available on the Unity Asset Store.
Contributing
Please read CONTRIBUTING.md for guidelines.
Release notes
Please see the Releases at https://github.com/aaubry/YamlDotNet/releases
Sponsorships
A big shout out to all of our sponsors
Showing the top 20 packages that depend on YamlDotNet.
Packages | Downloads |
---|---|
NSwag.Core.Yaml
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
46 |
Nuke.Common
Cross-platform build automation system
|
46 |
Nuke.Common
Cross-platform build automation system
|
45 |
Nuke.Common
Cross-platform build automation system
|
44 |
Nuke.Common
Cross-platform build automation system
|
41 |
Nuke.Common
Cross-platform build automation system
|
40 |
Nuke.Common
Cross-platform build automation system
|
38 |
Nuke.Common
Cross-platform build automation system
|
37 |
Nuke.Common
Cross-platform build automation system
Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit 'a69c742b7862fb624781dc20b2d9b8c088e98410' (see contained AppVeyorSettings.json file for build settings).
|
35 |
Nuke.Common
Cross-platform build automation system
|
35 |
Nuke.Common
Cross-platform build automation system
Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit '39132f3fb1fea9f889894dfe520cf4434d6eca4e' (see contained AppVeyorSettings.json file for build settings).
|
33 |
Nuke.Common
Cross-platform build automation system
|
33 |
NSwag.Core.Yaml
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
32 |
Nuke.Common
Cross-platform build automation system
Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit '4a24cd4e78d43b59deb8aa2033c696c8ceb51dd6' (see contained AppVeyorSettings.json file for build settings).
|
31 |
NSwag.Core.Yaml
NSwag: The Swagger API toolchain for .NET and TypeScript
|
31 |
.NET Framework 4.7
- No dependencies.
.NET 6.0
- No dependencies.
.NET 8.0
- No dependencies.
.NET Standard 2.0
- No dependencies.
.NET Standard 2.1
- No dependencies.
Version | Downloads | Last updated |
---|---|---|
16.2.1 | 0 | 12/01/2024 |
16.2.0 | 6 | 11/10/2024 |
16.1.3 | 5 | 10/05/2024 |
16.1.2 | 4 | 09/16/2024 |
16.1.1 | 4 | 09/16/2024 |
16.1.0 | 7 | 09/03/2024 |
16.0.0 | 7 | 07/15/2024 |
15.3.0 | 6 | 06/27/2024 |
15.1.6 | 23 | 05/31/2024 |
15.1.4 | 6 | 05/15/2024 |
15.1.2 | 18 | 03/09/2024 |
15.1.1 | 11 | 02/13/2024 |
15.1.0 | 23 | 02/13/2024 |
13.7.1 | 16 | 10/23/2023 |
13.7.0 | 16 | 10/17/2023 |
13.5.2 | 15 | 10/22/2023 |
13.5.1 | 9 | 12/28/2023 |
13.5.0 | 15 | 10/23/2023 |
13.4.0 | 10 | 10/24/2023 |
13.3.1 | 19 | 09/21/2023 |
13.2.0 | 15 | 08/27/2023 |
13.1.1 | 19 | 10/18/2023 |
13.1.0 | 25 | 05/31/2023 |
13.0.2 | 11 | 08/31/2023 |
13.0.1 | 11 | 02/17/2024 |
13.0.0 | 24 | 07/16/2023 |
12.3.1 | 15 | 08/30/2023 |
12.3.0 | 21 | 08/29/2023 |
12.2.1 | 17 | 08/28/2023 |
12.2.0 | 18 | 08/31/2023 |
12.1.0 | 20 | 08/28/2023 |
12.0.2 | 40 | 07/14/2023 |
12.0.1 | 13 | 08/16/2023 |
12.0.0 | 20 | 08/29/2023 |
11.2.1 | 35 | 04/24/2023 |
11.2.0 | 13 | 02/17/2024 |
11.1.3-nullable-enums-0003 | 22 | 10/12/2023 |
11.1.1 | 30 | 08/25/2023 |
11.1.0 | 15 | 08/25/2023 |
11.0.1 | 12 | 08/25/2023 |
10.1.0 | 5 | 08/26/2023 |
10.0.0 | 37 | 07/21/2023 |
9.1.4 | 60 | 07/08/2021 |
8.1.2 | 17 | 12/30/2023 |
8.1.0 | 16 | 06/12/2023 |
8.0.0 | 25 | 05/15/2023 |
7.0.0 | 31 | 06/11/2023 |
6.1.2 | 38 | 05/30/2023 |
6.1.1 | 26 | 06/11/2023 |
6.0.0 | 18 | 06/12/2023 |
5.4.0 | 32 | 06/12/2023 |
5.3.1 | 17 | 06/12/2023 |
5.3.0 | 10 | 06/13/2023 |
5.1.0 | 24 | 06/12/2023 |