PhilPuglisi / YamlDotNet

YamlDotNet is a .NET library for YAML

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

YamlDotNet

Travis Appveyor NuGet
Travis CI Build status 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.1
  • netstandard 1.3
  • .NET Framework 4.5
  • Unity Subset v3.5

The following runtimes are also supported, with a few features missing:

  • .NET Framework 3.5
  • .NET Framework 2.0

The library is compatible with mono's Ahead-of-Time compilation (AOT), and should work correctly on platforms that depend on it, such as Unity.

Quick start

Here are some quick samples to get you started.

Deserialization from a string

using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
...

string yaml;
//
var deserializer = new DeserializerBuilder()
    .WithNamingConvention(CamelCaseNamingConvention.Instance)
    .Build();

var order = deserializer.Deserialize<Order>(yaml);

Serialisation to a string

using YamlDotNet.RepresentationModel;
...

var objectToSerialize;
...
var serializer = new SerializerBuilder().Build();
//yaml contains a string containing your YAML
var yaml = serializer.Serialize(receipt);

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

Release notes for the latest version

About

YamlDotNet is a .NET library for YAML

License:MIT License


Languages

Language:C# 99.1%Language:PowerShell 0.5%Language:Shell 0.3%Language:Dockerfile 0.1%