Does the C # YamlDotNet library support a merge key?

I have a problem with the C # YamlDotNet library http://www.aaubry.net/page/YamlDotNet

Do you know if the Merge Key library is supported? http://yaml.org/type/merge.html

This does not work for me. In other libraries like PyYaml, merging works fine.

+4
source share
1 answer

Edit

YamlDotNet now has merge key support.

An example :

using System; using System.IO; using System.Collections.Generic; using YamlDotNet.Serialization; using YamlDotNet.Core; public class Program { public static void Main() { var yaml = @" anchor: &default key1: &myValue value1 key2: value2 alias: <<: *default key2: Overriding key2 key3: value3 "; var reader = new EventReader(new MergingParser(new Parser(new StringReader(yaml)))); var deserializer = new Deserializer(); var result = deserializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(reader); var alias = result["alias"]; Console.WriteLine("key1 = {0}", alias["key1"]); Console.WriteLine("key2 = {0}", alias["key2"]); } } 

Output:

 key1 = value1 key2 = Overriding key2 

Merge keys are not yet supported. This is a planned feature, but now you have to implement it yourself.

+1
source

All Articles