{"id":33322586,"url":"https://github.com/hadashiA/VYaml","last_synced_at":"2025-11-24T23:00:44.057Z","repository":{"id":64701131,"uuid":"497609306","full_name":"hadashiA/VYaml","owner":"hadashiA","description":"The extra fast, low memory footprint YAML library for C#,  focued on .NET and Unity.","archived":false,"fork":false,"pushed_at":"2025-07-06T02:03:45.000Z","size":1358,"stargazers_count":415,"open_issues_count":22,"forks_count":34,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-10T16:39:50.644Z","etag":null,"topics":["serialization","unity","yaml"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hadashiA.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"hadashiA"}},"created_at":"2022-05-29T14:08:07.000Z","updated_at":"2025-11-07T14:37:51.000Z","dependencies_parsed_at":"2024-01-29T03:32:06.745Z","dependency_job_id":"b9e2915f-fb2c-48c8-9115-b3901c9c0d47","html_url":"https://github.com/hadashiA/VYaml","commit_stats":null,"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"purl":"pkg:github/hadashiA/VYaml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadashiA%2FVYaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadashiA%2FVYaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadashiA%2FVYaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadashiA%2FVYaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hadashiA","download_url":"https://codeload.github.com/hadashiA/VYaml/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadashiA%2FVYaml/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286079811,"owners_count":27282121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-24T02:00:07.096Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["serialization","unity","yaml"],"created_at":"2025-11-20T04:00:37.029Z","updated_at":"2025-11-24T23:00:44.034Z","avatar_url":"https://github.com/hadashiA.png","language":"C#","funding_links":["https://github.com/sponsors/hadashiA"],"categories":["Source Generators"],"sub_categories":["Serialization"],"readme":"# VYaml\n\n[![GitHub license](https://img.shields.io/github/license/hadashiA/VYaml)](./LICENSE)\n![Unity 2022.2+](https://img.shields.io/badge/unity-2021.3+-000.svg)\n[![NuGet](https://img.shields.io/nuget/v/VYaml.svg)](https://www.nuget.org/packages/VYaml)\n\nVYaml is a pure C# YAML 1.2 implementation, which is extra fast, low memory footprint with focued on .NET and Unity.\n\n- The parser is heavily influenced by [yaml-rust](https://github.com/chyh1990/yaml-rust), and libyaml, yaml-cpp.\n- Serialization interface/implementation is heavily influenced by [Utf8Json](https://github.com/neuecc/Utf8Json), [MessagePack-CSharp](https://github.com/neuecc/MessagePack-CSharp), [MemoryPack](https://github.com/Cysharp/MemoryPack).\n\nThe reason VYaml is fast is it handles utf8 byte sequences directly with newface api set of C# (`System.Buffers.*`, etc).\nIn parsing, scalar values are pooled and no allocation occurs until `Scalar.ToString()`. This works with very low memory footprint and low performance overhead, in environments such as Unity.\n\n![screenshot_benchmark_dotnet.png](./screenshots/screenshot_benchmark_dotnet.png)\n![screenshot_benchmark_unity.png](./screenshots/screenshot_benchmark_unity.png)\n\nCompared with [YamlDotNet](https://github.com/aaubry/YamlDotNet) (most popular yaml library in C#), basically 6x faster and about 1/50 heap allocations in some case.\n\n\n## Features\n\n- YAML Parser (Reader)\n  - [YAML 1.2 mostly supported](#httpsyamlorgspec122)\n  - Support Unity serialized weird YAML format\n      - https://forum.unity.com/threads/scene-files-invalid-yaml.355653/\n      - YAML automatically generated by Unity may contain the symbol `\"stripped\"` in the document start line. This is against the YAML specification, but VYaml supports this format.\n- YAML Emitter (Writer)\n  - Write primitive types.\n  - Write plain scalar, double-quoted scalar, literal scalar.\n  - Write block style sequence, flow style sequence, and block mapping.\n- Deserialize / Serialize\n  - Convert between YAML and C# user-defined types.\n  - Convert between YAML and primitive collection via `dynamic` .\n  - Support interface-typed and abstract class-typed objects.\n  - Support anchor (`\u0026`) and alias (`*`) in the YAML spec.\n  - Support multiple yaml documents to C# collection.\n  - Customization\n    - Rename key\n    - Ignore member\n- Mainly focused on Unity\n    - Only 2021.3 and higher (netstandard2.1 compatible)\n\n## Most recent roadmap\n\n- [ ] Support node tree representation\n\n## Installation\n\n### NuGet\n\nYou can install the following nuget package.\nhttps://www.nuget.org/packages/VYaml\n\n```bash\ndotnet add package VYaml\n```\n\n### Unity\n\n\u003e [!IMPORTANT]\n\u003e Starting with version 1.0, VYaml is now via NuGetForUnity.\n\u003e If you are using an older version, please follow these instructions to reinstall.\n\n\u003e [!NOTE]\n\u003e Requirements: Unity 2021.3 or later.\n\n1. Install NugetForUnity.\n2. Open the NuGet window by going to NuGet \u003e Manage NuGet Packages, search for the \"VYaml\" package, and install it.\n3. (Optional) Installing Unity-specific extensions:\n  - Open the Package Manager window by selecting Window \u003e Package Manager, then click on [+] \u003e Add package from git URL and enter the following URL:\n  - ```\n    https://github.com/hadashiA/VYaml.git?path=VYaml.Unity/Assets/VYaml#1.2.0\n    ```\n\n## Usage\n\n### Serialize / Deserialize\n\nDefine a struct or class to be serialized and annotate it with the `[YamlObject]` attribute and the partial keyword.\n\n```csharp\nusing VYaml.Annotations;\n\n[YamlObject]\npublic partial class Sample\n{\n    // By default, public fields and properties are serializable.\n    public string A; // public field\n    public string B { get; set; } // public property\n    public string C { get; private set; } // public property (private setter)\n    public string D { get; init; } // public property (init-only setter)\n\n    // use `[YamlIgnore]` to remove target of a public member\n    [YamlIgnore]\n    public int PublicProperty2 =\u003e PublicProperty + PublicField;\n}\n```\n\nWhy partial is necessary ?\n- VYaml uses [SourceGenerator](https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview) for metaprogramming, which supports automatic generation of partial declarations, sets to private fields.\n\n``` csharp\nvar utf8Yaml = YamlSerializer.Serialize(new Sample\n{\n    A = \"hello\",\n    B = \"foo\",\n    C = \"bar\",\n    D = \"hoge\",\n});\n```\n\n\nResult:\n\n```yaml\na: hello\nb: foo\nc: bar\nd: hoge\n```\n\nBy default, The `Serialize\u003cT\u003e` method returns an utf8 byte array. \nThis is because it is common for writes to files or any data stores to be stored as strings in utf8 format.\n\n\nIf you wish to receive the results in a C# string, do the following\nNote that this has the overhead of conversion to utf16.\n\n``` csharp\nvar yamlString = YamlSerializer.SerializeToString(...);\n```\n\nYou can also convert yaml to C#.\n\n```csharp\nusing var stream = File.OpenRead(\"/path/to/yaml\");\nvar sample = await YamlSerializer.DeserializeAsync\u003cSample\u003e(stream);\n\n// Or \n// var yamlUtf8Bytes = System.Text.Encoding.UTF8.GetBytes(\"\u003cyaml string....\u003e\");\n// var sample = YamlSerializer.Deserialize\u003cSample\u003e(yamlUtf8Bytes);\n```\n\n```csharp\nsample.A // #=\u003e \"hello\"\nsample.B // #=\u003e \"foo\"\nsample.C // #=\u003e \"bar\"\nsample.D // #=\u003e \"hoge\"\n```\n\n#### Built-in supported types\n\nThese types can be serialized by default:\n\n- .NET primitives (`byte`, `int`, `bool`, `char`, `double`, etc.)\n- Any enum (Currently, only simple string representation)\n- `string`, `decimal`, `Half`, `BigInteger`, `Complex`\n- `TimeSpan`, `DateTime`, `DateTimeOffset`\n- `Guid`, `Uri`, `Version`, `Type`\n- `byte[]` as base64 string\n- `T[]`, `T[,]`, `T[,,]`, `T[,,]`, `BitArray`\n- `Nullable\u003c\u003e`, `KeyValuePair\u003c,\u003e`, `Tuple\u003c,...\u003e`, `ValueTuple\u003c,...\u003e`\n- `List\u003c\u003e`, `Stack\u003c\u003e`, `Queue\u003c\u003e`, `LinkedList\u003c\u003e`, `HashSet\u003c\u003e`, `SortedSet\u003c\u003e`,  `BlockingCollection\u003c\u003e`, `ConcurrentQueue\u003c\u003e`, `ConcurrentStack\u003c\u003e`, `ConcurrentBag\u003c\u003e`\n- `Dictionary\u003c,\u003e`\n- `IEnumerable\u003c\u003e`, `ICollection\u003c\u003e`, `IList\u003c\u003e`, `IReadOnlyCollection\u003c\u003e`, `IReadOnlyList\u003c\u003e`, `ISet\u003c\u003e`\n- `IDictionary\u003c,\u003e`, `IReadOnlyDictionary\u003c,\u003e`\n\nThe following types of support are included in the package for Unity.\n\n- `Color`, `Color32`\n- `Vector2`, `Vector2Int`, `Vector3`, `Vector3Int`, `Vector4`, `Vector4Int`\n- `Matrix4x4`\n- `Quaternion`\n- `Rect`, `RectInt`, `RectOffset`\n- Addtionaly, If the `Unity.Mathmatics` package is installed, the following support is enabled:\n  - `bool2`, `bool3`, `bool4`\n  - `float2`, `float3`, `float4`\n  - `double2`, `double3`, `double4`\n  - `half2`, `half3`, `half4`\n  - `int2`, `int3`, `int4` \n  - `uint2`, `uint3`, `uint4` \n  - `bool2x2`, `bool2x3`, `bool2x4`, `bool3x2`, `bool3x3`, `bool3x4`, `bool4x2`, `bool4x3`, `bool4x4`\n  - `float2x2`, `float2x3`, `float2x4`, `float3x2`, `float3x3`, `float3x4`, `float4x2`, `float4x3`, `float4x4`\n  - `double2x2`, `double2x3`, `double2x4`, `double3x2`, `double3x3`, `double3x4`, `double4x2`, `double4x3`, `double4x4`\n  - `int2x2`, `int2x3`, `int2x4`, `int3x2`, `int3x3`, `int3x4`, `int4x2`, `int4x3`, `int4x4`\n  - `uint2x2`, `uint2x3`, `uint2x4`, `uint3x2`, `uint3x3`, `uint3x4`, `uint4x2`, `uint4x3`, `uint4x4`\n  - `quaternion`\n  \n\n- To enable it, do the following\n1. Install the unity package.\n    - See [Installation/Unity](#unity) section.\n2. Add UnityResolver to YamlSeriarOptions.\n    - ```cs\n      YamlSerializer.DefaultOptions = new YamlSerializerOptions\n      {\n          Resolver = CompositeResolver.Create(new IYamlFormatterResolver[]\n          {\n              StandardResolver.Instance,\n              UnityResolver.Instance,\n          })\n      };\n      ```\n\n#### Deserialize as `dynamic`\n\nYou can also deserialize into primitive `object` type implicitly.\n\n``` csharp\nvar yaml = YamlSerializer.Deserialize\u003cdynamic\u003e(yamlUtf8Bytes);\n```\n\n```csharp\nyaml[\"a\"] // #=\u003e \"hello\"\nyaml[\"b\"] // #=\u003e \"aaa\"\nyaml[\"c\"] // #=\u003e \"hoge\"\nyaml[\"d\"] // #=\u003e \"ddd\"\n```\n\n#### Deserialize multiple documents\n\n\nYAML allows for multiple data in one file by separating them with `---`. This is called a \"Document\".\nIf you want to load multiple documents, you can use `Yamlserializer.DeserializeMultipleDocuments\u003cT\u003e(...)`.\n\nFor example:\n\n``` yaml\n---\nTime: 2001-11-23 15:01:42 -5\nUser: ed\nWarning:\n  This is an error message\n  for the log file\n---\nTime: 2001-11-23 15:02:31 -5\nUser: ed\nWarning:\n  A slightly different error\n  message.\n---\nDate: 2001-11-23 15:03:17 -5\nUser: ed\nFatal:\n  Unknown variable \"bar\"\nStack:\n- file: TopClass.py\n  line: 23\n  code: |\n    x = MoreObject(\"345\\n\")\n- file: MoreClass.py\n  line: 58\n  code: |-\n    foo = bar\n```\n\n``` csharp\nvar documents = YamlSerializer.DeserializeMultipleDocuments\u003cdynamic\u003e(yaml);\n```\n\n```csharp\ndocuments[0][\"Warning\"] // #=\u003e \"This is an error message for the log file\"\ndocuments[1][\"Warning\"] // #=\u003e \"A slightly different error message.\"\ndocuments[2][\"Fatal\"]   // #=\u003e \"Unknown variable \\\"bar\\\"\"\n```\n\n#### Naming convention\n\n:exclamation: By default, VYaml maps C# property names in lower camel case (e.g. `propertyName`) format to yaml keys.\n\nIf you want to customize this behaviour, `YamlSerializerOptions.NamingConvention` to set it.\n\n```cs\nvar options = YamlSerializerOptions.Standard;\noptions.NamingConvention = NamingConvention.SnakeCase;\n\nYamlSerializer.Serialize(new A { FooBar = 123 }, options); // #=\u003e \"{ foo_bar: 123 }\"\n```\n\nList of possible values:\n- NamingConvention.LowerCamelCase\n  - Like `propertyName`\n- NamingConvention.UpperCamelCase:\n  - Like `PropertyName`\n- NamingConvention.SnakeCase:\n  - Like  `property_name`\n- NamingConvention.KebabCase:\n  - Like `property-name`\n\n\n\u003e [!TIP]\n\u003e If you specify an option other than the default `LowerCamelCase`, there will be a slight performance degradation at runtime.\n\nYou may specify NamingConvention for each type declaration by `[YamlObject]` attribute.\nIn this case, no performance degradation occurs.\n\n```csharp\n[YamlObject(NamingConvention.SnakeCase)]\npublic partial class Sample\n{\n    public int FooBar { get; init; }\n}\n```\n\nThis serialize as:\n\n```yaml\nfoo_bar: 100\n```\n\nAlso, you can change the key name each members with `[YamlMember(\"name\")]`\n\n```csharp\n[YamlObject]\npublic partial class Sample\n{\n    [YamlMember(\"foo-bar-alias\")]\n    public int FooBar { get; init; }\n}\n```\n\nThis serialize as:\n\n```yaml\nfoo-bar-alias: 100\n```\n\n#### Custom constructor\n\nVYaml supports both parameterized and parameterless constructors. The selection of the constructor follows these rules.\n\n- If there is `[YamlConstructor]`, use it.\n- If there is no explicit constructor use a parameterless one.\n- If there is one constructor use it.\n- If there are multiple constructors, then the `[YamlConstructor]` attribute must be applied to the desired constructor (the generator will not automatically choose one), otherwise the generator will emit an error.\n\n:note: If using a parameterized constructor, all parameter names must match corresponding member names (case-insensitive).\n\n``` csharp\n[YamlObject]\npublic partial class Person\n{\n    public int Age { get; } \n    public string Name { get; }\n\n    // You can use a parameterized constructor - parameter names must match corresponding members name (case-insensitive)\n    public Person(int age, string name)\n    {\n        Age = age;\n        Name = name;\n    }\n}\n\n[YamlObject]\npublic partial class Person\n{\n    public int Age { get; set; }\n    public string Name { get; set; }\n    \n    public Person()\n    {\n        // ...\n    }\n\n    // If there are multiple constructors, then [YamlConstructor] should be used\n    [YamlConstructor]\n    public Person(int age, string name)\n    {\n        this.Age = age;\n        this.Name = name;\n    }\n}\n\n\n[YamlObject]\npublic partial class Person\n{\n    public int Age { get; } // from constructor\n    public string Name { get; } // from constructor\n    public string Profile { get; set; } // from setter\n\n    // If all members of the construct are not taken as arguments, setters are used for the other members\n    public Person(int age, string name)\n    {\n        this.Age = age;\n        this.Name = name;\n    }\n}\n```\n\n#### Enum\n\nBy default, Enum is serialized in camelCase with a leading lowercase letter, as is the key name of the object. \nFor example:\n\n``` csharp\nenum Foo\n{\n    Item1,\n    Item2,\n    Item3,\n}\n```\n\n``` csharp\nYamlSerializer.Serialize(Foo.Item1); // #=\u003e \"item1\"\n```\n\nIt respect `[EnumMember]`, and `[DataMember]`.\n\n\n``` csharp\nenum Foo\n{\n    [EnumMember(Value = \"item1-alias\")]\n    Item1,\n    \n    [EnumMember(Value = \"item2-alias\")]\n    Item2,\n    \n    [EnumMember(Value = \"item3-alias\")]\n    Item3,\n}\n```\n\n``` csharp\nYamlSerializer.Serialize(Foo.Item1); // #=\u003e \"item1-alias\"\n```\n\nAnd, naming covnention can also be specified by using the `[YamlMember]` attribute.\n\n\n``` csharp\n[YamlObject(NamingConvention.SnakeCase)]\nenum Foo\n{\n    ItemOne,\n    ItemTwo,\n    ItemThree,\n}\n```\n\n``` csharp\nYamlSerializer.Serialize(Foo.ItemOne); // #=\u003e \"item_one\"\n```\n\n#### Polymorphism (Union)\n\nVYaml supports deserialize interface or abstract class objects for. In VYaml this feature is called Union. \nOnly interfaces and abstracts classes are allowed to be annotated with `[YamlObjectUnion]` attributes. Unique union tags are required.\n\n``` csharp\n[YamlObject]\n[YamlObjectUnion(\"!foo\", typeof(FooClass))]\n[YamlObjectUnion(\"!bar\", typeof(BarClass))]\npublic partial interface IUnionSample\n{\n}\n\n[YamlObject]\npublic partial class FooClass : IUnionSample\n{\n    public int A { get; set; }\n}\n\n[YamlObject]\npublic partial class BarClass : IUnionSample\n{\n    public string? B { get; set; }\n}\n```\n\n``` csharp\n// We can deserialize as interface type.\nvar obj = YamlSerializer.Deserialize\u003cIUnionSample\u003e(UTF8.GetBytes(\"!foo { a: 100 }\"));\n\nobj.GetType(); // #=\u003e FooClass\n```\n\nIn the abobe example, The `!foo` and `!bar`  are called tag in the YAML specification.\nYAML can mark arbitrary data in this way, and VYaml Union takes advantage of this.\n\nYou can also serialize:\n\n``` csharp\nYamlSerializer.Serialize\u003cIUnionSample\u003e(new FooClass { A = 100 });\n```\n\nResult:\n``` yaml\n!foo\na: 100\n```\n\n## Customize serialization behaviour\n\n- `IYamlFormatter\u003cT\u003e` is an interface customize the serialization behaviour of a your particular type.\n- `IYamlFormatterResolver` is an interface can customize how it searches for `IYamlFormatter\u003cT\u003e` at runtime.\n\nTo perform Serialize/Deserialize, it need an `IYamlFormatter\u003cT\u003e` corresponding to a certain C# type.  \nBy default, the following `StandardResolver` works and identifies IYamlFormatter\u003cT\u003e.\n\n\nYou can customize this behavior as follows:\n\n``` csharp\nvar options = new YamlSerializerOptions\n{\n    Resolver = CompositeResolver.Create(\n        new IYamlFormatter[]\n        {\n            new YourCustomFormatter1(), // You can add additional formatter\n        },\n        new IYamlFormatterResolver[]\n        {\n            new YourCustomResolver(),  // You can add additional resolver\n            StandardResolver.Instance, // Fallback to default behavior at the end.\n        })\n};\n        \nYamlSerializer.Deserialize\u003cT\u003e(yaml, options);\nYamlSerializer.Deserialize\u003cT\u003e(yaml, options);\n```\n\n\n## Low-Level API\n\n### Parser\n\n`YamlParser` struct provides access to the complete meta-information of yaml.\n\n\n- `YamlParser.Read()` reads through to the next syntax on yaml. (If end of stream then return false.)\n- `YamlParser.ParseEventType` indicates the state of the currently read yaml parsing result.\n- How to access scalar value:\n    - `YamlParser.GetScalarAs*` families take the result of converting a scalar at the current position to a specified type.\n    - `YamlParser.TryGetScalarAs*` families return true and take a result if the current position is a scalar and of the specified type.\n    - `YamlParser.ReadScalarAs*` families is similar to GetScalarAs*, but advances the present position to after the scalar read.\n- How to access meta information:\n    - `YamlParser.TryGetCurrentTag(out Tag tag)` \n    - `YamlParser.TryGetCurrentAnchor(out Anchor anchor)`\n\nBasic example:\n\n```csharp\nvar parser = YamlParser.FromBytes(utf8Bytes);\n\n// YAML contains more than one `Document`. \n// Here we skip to before first document content.\nparser.SkipAfter(ParseEventType.DocumentStart);\n\n// Scanning...\nwhile (parser.Read())\n{\n    // If the current syntax is Scalar, \n    if (parser.CurrentEventType == ParseEventType.Scalar)\n    {\n        var intValue = parser.GetScalarAsInt32();\n        var stringValue = parser.GetScalarAsString();\n        // ...\n        \n        if (parser.TryGetCurrentTag(out var tag))\n        {\n            // Check for the tag...\n        }\n        \n        if (parser.TryGetCurrentAnchor(out var anchor))\n        {\n            // Check for the anchor...\n        }        \n    }\n    \n    // If the current syntax is Sequence (Like a list in yaml)\n    else if (parser.CurrentEventType == ParseEventType.SequenceStart)\n    {\n        // We can check for the tag...\n        // We can check for the anchor...\n        \n        parser.Read(); // Skip SequenceStart\n\n        // Read to end of sequence\n        while (!parser.End \u0026\u0026 parser.CurrentEventType != ParseEventType.SequenceEnd)\n        {\n             // A sequence element may be a scalar or other...\n             if (parser.CurrentEventType == ParseEventType.Scalar)\n             {\n                 // ...\n             }\n             // ...\n             // ...\n             else\n             {\n                 // We can skip current element. (It could be a scalar, or alias, sequence, mapping...)\n                 parser.SkipCurrentNode();\n             }\n        }\n        parser.Read(); // Skip SequenceEnd.\n    }\n    \n    // If the current syntax is Mapping (like a Dictionary in yaml)\n    else if (parser.CurrentEventType == ParseEventType.MappingStart)\n    {\n        // We can check for the tag...\n        // We can check for the anchor...\n        \n        parser.Read(); // Skip MappingStart\n\n        // Read to end of mapping\n        while (parser.CurrentEventType != ParseEventType.MappingEnd)\n        {\n             // After Mapping start, key and value appear alternately.\n             \n             var key = parser.ReadScalarAsString();  // if key is scalar\n             var value = parser.ReadScalarAsString(); // if value is scalar\n             \n             // Or we can skip current key/value. (It could be a scalar, or alias, sequence, mapping...)\n             // parser.SkipCurrentNode(); // skip key\n             // parser.SkipCurrentNode(); // skip value\n        }\n        parser.Read(); // Skip MappingEnd.\n    }\n    \n    // Alias\n    else if (parser.CurrentEventType == ParseEventType.Alias)\n    {\n        // If Alias is used, the previous anchors must be holded somewhere.\n        // In the High level Deserialize API, `YamlDeserializationContext` does exactly this. \n    }\n}\n```\n\nSee [test code](https://github.com/hadashiA/VYaml/blob/master/VYaml.Tests/Parser/SpecTest.cs) for more information.\nThe above test covers various patterns for the order of `ParsingEvent`.\n\n\n### Emitter\n\n`Utf8YamlEmitter` struct provides to write YAML formatted string.\n\nBasic usage:\n\n``` csharp\nvar buffer = new ArrayBufferWriter\u003cbyte\u003e();\nvar emitter = new Utf8YamlEmitter(buffer); // It needs buffer implemented `IBufferWriter\u003cbyte\u003e`\n\nemitter.BeginMapping(); // Mapping is a collection like Dictionary in YAML\n{\n    emitter.WriteString(\"key1\");\n    emitter.WriteString(\"value-1\");\n    \n    emitter.WriteString(\"key2\");\n    emitter.WriteInt32(222);\n    \n    emitter.WriteString(\"key3\");\n    emitter.WriteFloat(3.333f);\n}\nemitter.EndMapping();\n```\n\n``` csharp\n// If you want to expand a string in memory, you can do this.\nSystem.Text.Encoding.UTF8.GetString(buffer.WrittenSpan); \n```\n\n``` yaml\nkey1: value-1\nkey2: 222\nkey3: 3.333\n```\n\n#### Emit string in various formats\n\nBy default, WriteString() automatically determines the format of a scalar. \n\n\nMulti-line strings are automatically format as a literal scalar:\n\n``` csharp\nemitter.WriteString(\"Hello,\\nWorld!\\n\");\n```\n\n``` yaml\n|\n  Hello,\n  World!\n```\n\nSpecial characters contained strings are automatically quoted.\n\n``` csharp\nemitter.WriteString(\"\u0026aaaaa \");\n```\n\n``` yaml\n\"\u0026aaaaa \"\n```\n\nOr you can specify the style explicitly:\n\n``` csharp\nemitter.WriteString(\"aaaaaaa\", ScalarStyle.Literal);\n```\n\n``` yaml\n|-\n  aaaaaaaa\n```\n\n#### Emit sequences and other structures\n\ne.g:\n\n``` csharp\nemitter.BeginSequence();\n{\n    emitter.BeginSequence(SequenceStyle.Flow);\n    {\n        emitter.WriteInt32(100);\n        emitter.WriteString(\"\u0026hoge\");\n        emitter.WriteString(\"bra\");\n    }\n    emitter.EndSequence();\n    \n    emitter.BeginMapping();\n    {\n        emitter.WriteString(\"key1\");\n        emitter.WriteString(\"item1\");\n        \n        emitter.WriteString(\"key2\");\n        emitter.BeginSequence();\n        {\n            emitter.WriteString(\"nested-item1\")\n            emitter.WriteString(\"nested-item2\")\n            emitter.BeginMapping();\n            {\n                emitter.WriteString(\"nested-key1\")\n                emitter.WriteInt32(100)\n            }\n            emitter.EndMapping();\n        }\n        emitter.EndSequence();\n    }\n    emitter.EndMapping();\n}\nemitter.EndMapping();\n```\n\n``` yaml\n- [100, \"\u0026hoge\", bra]\n- key1: item1\n  key2:\n  - nested-item1\n  - nested-item2\n  - nested-key1: 100\n```\n    \n## YAML 1.2 spec support status\n\n### Implicit primitive type conversion of scalar\n\nThe following is the default implicit type interpretation.\n\nBasically, it follows YAML Core Schema.\nhttps://yaml.org/spec/1.2.2/#103-core-schema\n\n|Support|Regular expression|Resolved to type|\n|:-----|:-------|:-------|\n| :white_check_mark: | `null \\| Null \\| NULL \\| ~` | null |\n| :white_check_mark: | `/* Empty */` | null |\n| :white_check_mark: | `true \\| True \\| TRUE \\| false \\| False \\| FALSE` | boolean |\n| :white_check_mark: | `[-+]? [0-9]+` | int  (Base 10) |\n| :white_check_mark: | `0o [0-7]+` | int (Base 8) |\n| :white_check_mark: | `0x [0-9a-fA-F]+` | int (Base 16) |\n| :white_check_mark: | `[-+]? ( \\. [0-9]+ \\| [0-9]+ ( \\. [0-9]* )? ) ( [eE] [-+]? [0-9]+ )?` | float |\n| :white_check_mark: | `[-+]? ( \\.inf \\| \\.Inf \\| \\.INF )` | float (Infinity) |\n| :white_check_mark: | `\\.nan \\| \\.NaN \\| \\.NAN` | float (Not a number) |\n\n### https://yaml.org/spec/1.2.2/\n\nFollowing is the results of the [test](https://github.com/hadashiA/VYaml/blob/master/VYaml.Tests/Parser/SpecTest.cs) for the examples from the  [yaml spec page](https://yaml.org/spec/1.2.2/).\n\n- 2.1. Collections\n  - :white_check_mark: Example 2.1 Sequence of Scalars (ball players)\n  - :white_check_mark: Example 2.2 Mapping Scalars to Scalars (player statistics)\n  - :white_check_mark: Example 2.3 Mapping Scalars to Sequences (ball clubs in each league)\n  - :white_check_mark: Example 2.4 Sequence of Mappings (players statistics)\n  - :white_check_mark: Example 2.5 Sequence of Sequences\n  - :white_check_mark: Example 2.6 Mapping of Mappings\n- 2.2. Structures\n  - :white_check_mark: Example 2.7 Two Documents in a Stream (each with a leading comment)\n  - :white_check_mark: Example 2.8 Play by Play Feed from a Game\n  - :white_check_mark: Example 2.9 Single Document with Two Comments\n  - :white_check_mark: Example 2.10 Node for Sammy Sosa appears twice in this document\n  - :white_check_mark: Example 2.11 Mapping between Sequences\n  - :white_check_mark: Example 2.12 Compact Nested Mapping\n- 2.3. Scalars\n  - :white_check_mark: Example 2.13 In literals, newlines are preserved\n  - :white_check_mark: Example 2.14 In the folded scalars, newlines become spaces\n  - :white_check_mark: Example 2.15 Folded newlines are preserved for more indented and blank lines\n  - :white_check_mark: Example 2.16 Indentation determines scope\n  - :white_check_mark: Example 2.17 Quoted Scalars\n  - :white_check_mark: Example 2.18 Multi-line Flow Scalars\n- 2.4. Tags\n  - :white_check_mark: Example 2.19 Integers\n  - :white_check_mark: Example 2.20 Floating Point\n  - :white_check_mark: Example 2.21 Miscellaneous\n  - :white_check_mark: Example 2.22 Timestamps\n  - :white_check_mark: Example 2.23 Various Explicit Tags\n  - :white_check_mark: Example 2.24 Global Tags\n  - :white_check_mark: Example 2.25 Unordered Sets\n  - :white_check_mark: Example 2.26 Ordered Mappings\n- 2.5. Full Length Example\n  - :white_check_mark: Example 2.27 Invoice\n  - :white_check_mark: Example 2.28 Log File\n- 5.2. Character Encodings\n  - :white_check_mark: Example 5.1 Byte Order Mark\n  - :white_check_mark: Example 5.2 Invalid Byte Order Mark\n- 5.3. Indicator Characters\n  - :white_check_mark: Example 5.3 Block Structure Indicators\n  - :white_check_mark: Example 5.4 Flow Collection Indicators\n  - :white_check_mark: Example 5.5 Comment Indicator\n  - :white_check_mark: Example 5.6 Node Property Indicators\n  - :white_check_mark: Example 5.7 Block Scalar Indicators\n  - :white_check_mark: Example 5.8 Quoted Scalar Indicators\n  - :white_check_mark: Example 5.9 Directive Indicator\n  - :white_check_mark: Example 5.10 Invalid use of Reserved Indicators\n- 5.4. Line Break Characters\n  - :white_check_mark: Example 5.11 Line Break Characters\n  - :white_check_mark: Example 5.12 Tabs and Spaces\n  - :white_check_mark: Example 5.13 Escaped Characters\n  - :white_check_mark: Example 5.14 Invalid Escaped Characters\n- 6.1. Indentation Spaces\n  - :white_check_mark: Example 6.1 Indentation Spaces\n  - :white_check_mark: Example 6.2 Indentation Indicators\n- 6.2. Separation Spaces\n  - :white_check_mark: Example 6.3 Separation Spaces\n- 6.3. Line Prefixes\n  - :white_check_mark: Example 6.4 Line Prefixes\n- 6.4. Empty Lines\n  - :white_check_mark: Example 6.5 Empty Lines\n- 6.5. Line Folding\n  - :white_check_mark: Example 6.6 Line Folding\n  - :white_check_mark: Example 6.7 Block Folding\n  - :white_check_mark: Example 6.8 Flow Folding\n- 6.6. Comments\n  - :white_check_mark: Example 6.9 Separated Comment\n  - :white_check_mark: Example 6.10 Comment Lines\n  - :white_check_mark: Example 6.11 Multi-Line Comments\n- 6.7. Separation Lines\n  - :white_check_mark: Example 6.12 Separation Spaces\n- 6.8. Directives\n  - :white_check_mark: Example 6.13 Reserved Directives\n  - :white_check_mark: Example 6.14 YAML directive\n  - :white_check_mark: Example 6.15 Invalid Repeated YAML directive\n  - :white_check_mark: Example 6.16 TAG directive\n  - :white_check_mark: Example 6.17 Invalid Repeated TAG directive\n  - :white_check_mark: Example 6.18 Primary Tag Handle\n  - :white_check_mark: Example 6.19 Secondary Tag Handle\n  - :white_check_mark: Example 6.20 Tag Handles\n  - :white_check_mark: Example 6.21 Local Tag Prefix\n  - :white_check_mark: Example 6.22 Global Tag Prefix\n- 6.9. Node Properties\n  - :white_check_mark: Example 6.23 Node Properties\n  - :white_check_mark: Example 6.24 Verbatim Tags\n  - :white_check_mark: Example 6.25 Invalid Verbatim Tags\n  - :white_check_mark: Example 6.26 Tag Shorthands\n  - :white_check_mark: Example 6.27 Invalid Tag Shorthands\n  - :white_check_mark: Example 6.28 Non-Specific Tags\n  - :white_check_mark: Example 6.29 Node Anchors\n- 7.1. Alias Nodes\n  - :white_check_mark: Example 7.1 Alias Nodes\n- 7.2. Empty Nodes\n  - :white_check_mark: Example 7.2 Empty Content\n  - :white_check_mark: Example 7.3 Completely Empty Flow Nodes\n- 7.3. Flow Scalar Styles\n  - :white_check_mark: Example 7.4 Double Quoted Implicit Keys\n  - :white_check_mark: Example 7.5 Double Quoted Line Breaks\n  - :white_check_mark: Example 7.6 Double Quoted Lines\n  - :white_check_mark: Example 7.7 Single Quoted Characters\n  - :white_check_mark: Example 7.8 Single Quoted Implicit Keys\n  - :white_check_mark: Example 7.9 Single Quoted Lines\n  - :white_check_mark: Example 7.10 Plain Characters\n  - :white_check_mark: Example 7.11 Plain Implicit Keys\n  - :white_check_mark: Example 7.12 Plain Lines\n- 7.4. Flow Collection Styles\n  - :white_check_mark: Example 7.13 Flow Sequence\n  - :white_check_mark: Example 7.14 Flow Sequence Entries\n  - :white_check_mark: Example 7.15 Flow Mappings\n  - :white_check_mark: Example 7.16 Flow Mapping Entries\n  - :white_check_mark: Example 7.17 Flow Mapping Separate Values\n  - :white_check_mark: Example 7.18 Flow Mapping Adjacent Values\n  - :white_check_mark: Example 7.20 Single Pair Explicit Entry\n  - :x: Example 7.21 Single Pair Implicit Entries\n  - :white_check_mark: Example 7.22 Invalid Implicit Keys\n  - :white_check_mark: Example 7.23 Flow Content\n  - :white_check_mark: Example 7.24 Flow Nodes\n- 8.1. Block Scalar Styles\n  - :white_check_mark: Example 8.1 Block Scalar Header\n  - :x: Example 8.2 Block Indentation Indicator\n  - :white_check_mark: Example 8.3 Invalid Block Scalar Indentation Indicators\n  - :white_check_mark: Example 8.4 Chomping Final Line Break\n  - :white_check_mark: Example 8.5 Chomping Trailing Lines\n  - :white_check_mark: Example 8.6 Empty Scalar Chomping\n  - :white_check_mark: Example 8.7 Literal Scalar\n  - :white_check_mark: Example 8.8 Literal Content\n  - :white_check_mark: Example 8.9 Folded Scalar\n  - :white_check_mark: Example 8.10 Folded Lines\n  - :white_check_mark: Example 8.11 More Indented Lines\n  - :white_check_mark: Example 8.12 Empty Separation Lines\n  - :white_check_mark: Example 8.13 Final Empty Lines\n  - :white_check_mark: Example 8.14 Block Sequence\n  - :white_check_mark: Example 8.15 Block Sequence Entry Types\n  - :white_check_mark: Example 8.16 Block Mappings\n  - :white_check_mark: Example 8.17 Explicit Block Mapping Entries\n  - :white_check_mark: Example 8.18 Implicit Block Mapping Entries\n  - :white_check_mark: Example 8.19 Compact Block Mappings\n  - :white_check_mark: Example 8.20 Block Node Types\n  - :white_check_mark: Example 8.21 Block Scalar Nodes\n  - :white_check_mark: Example 8.22 Block Collection Nodes\n\n## Credits\n\nVYaml is inspired by:\n\n- [yaml-rust](https://github.com/chyh1990/yaml-rust)\n- [Utf8Json](https://github.com/neuecc/Utf8Json), [MessagePack-CSharp](https://github.com/neuecc/MessagePack-CSharp), [MemoryPack](https://github.com/Cysharp/MemoryPack)\n\n## Aurhor\n\n[@hadashiA](https://github.com/hadashiA)\n\n## License\n\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FhadashiA%2FVYaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FhadashiA%2FVYaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FhadashiA%2FVYaml/lists"}