Meziantou.Framework.Yamlish 2.0.2

Prefix Reserved
dotnet add package Meziantou.Framework.Yamlish --version 2.0.2
                    
NuGet\Install-Package Meziantou.Framework.Yamlish -Version 2.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Meziantou.Framework.Yamlish" Version="2.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Meziantou.Framework.Yamlish" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Meziantou.Framework.Yamlish" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Meziantou.Framework.Yamlish --version 2.0.2
                    
#r "nuget: Meziantou.Framework.Yamlish, 2.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Meziantou.Framework.Yamlish@2.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Meziantou.Framework.Yamlish&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Meziantou.Framework.Yamlish&version=2.0.2
                    
Install as a Cake Tool

Meziantou.Framework.Yamlish

Meziantou.Framework.Yamlish parses and writes a small, deliberate subset of YAML:

  • Mappings using property: value
  • Nested mappings and block sequences using indentation
  • Scalar-only inline sequences using []
  • Plain, single-quoted, double-quoted, literal block (|, |-, |+), and folded block (>, >-, >+) strings
  • Full-line and trailing comments using #

It intentionally does not support the complete YAML specification.

Parse a document

using Meziantou.Framework.Yamlish;

var document = YamlishDocument.Parse("""
    id: abc
    name: sample product
    description: |
        This is a sample product.
        Line 2
    """);

var product = (YamlishMapping)document.Root;
var id = ((YamlishScalar)product["id"]).Value;

Serialize and deserialize objects

using Meziantou.Framework.Yamlish;

var options = new YamlishSerializerOptions
{
    PropertyNamingPolicy = YamlishNamingPolicy.SnakeCaseLower,
};

var content = YamlishSerializer.Serialize(new Product
{
    Id = "abc",
    IsAvailable = true,
}, options);

var product = YamlishSerializer.Deserialize<Product>(content, options);

Plain scalar values remain strings in the document model. During typed deserialization, they are converted to the requested .NET property type using invariant culture.

Built-in converters support strings, characters, booleans, all integral and floating-point types, decimals, big integers, complex numbers, bit arrays, byte arrays and byte memories, cultures, enums, GUIDs, dates, times, time spans, HTTP scalar values, network addresses, types, URIs, and versions. Temporal and floating-point values use round-trip formats.

Properties and fields can be conditionally omitted using YamlishIgnoreAttribute. The global default is configured using YamlishSerializerOptions.DefaultIgnoreCondition.

var options = new YamlishSerializerOptions
{
    DefaultIgnoreCondition = YamlishIgnoreCondition.WhenWritingNull,
};

public sealed class Product
{
    [YamlishIgnore(Condition = YamlishIgnoreCondition.WhenWritingDefault)]
    public decimal Price { get; set; }
}

Attributes can also be added using serializer options. Option-provided attributes override attributes declared on the member.

var options = new YamlishSerializerOptions();
options.AddAttribute(typeof(Product), nameof(Product.IsAvailable), new YamlishIgnoreAttribute());
options.AddAttribute<Product>(product => product.Price, new YamlishPropertyNameAttribute("cost"));
options.AddPropertyAttribute(property => property.PropertyType == typeof(Uri), new YamlishIgnoreAttribute());

Serializer options become read-only after their first use. Resolved member metadata is then cached by type and reused by subsequent serialization and deserialization operations.

Converters

Custom converters can read and write any YamlishNode shape. The converter list contains all default converters and can be reordered, extended, or have converters removed before its first use. Converters are checked in collection order and resolved converters are cached after the options become read-only.

var options = new YamlishSerializerOptions();
options.Converters.Insert(0, new TemperatureConverter());

public sealed class TemperatureConverter : YamlishConverter<Temperature>
{
    public override Temperature Read(YamlishNode node, YamlishSerializerOptions options)
        => new(int.Parse(((YamlishScalar)node).Value, CultureInfo.InvariantCulture));

    public override YamlishNode Write(Temperature value, YamlishSerializerOptions options)
        => new YamlishScalar(value.Value.ToString(CultureInfo.InvariantCulture));
}

Use YamlishConverterFactory to create converters for open generic types or families of related types.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net11.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.2 184 7/7/2026
2.0.0 105 7/5/2026
1.0.5 125 6/17/2026
1.0.4 116 6/16/2026
1.0.3 106 6/16/2026
1.0.2 121 6/16/2026
1.0.1 116 6/16/2026
1.0.0 109 6/16/2026