Questions tagged [yamldotnet]

YamlDotNet is a .NET library for YAML

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.

The most up-to-date version can always be found right from Visual studio by installing following NuGet package - YamlDotNet.

PM> Install-Package YamlDotNet

Documentation can be found on the official page.

188 questions
5
votes
0 answers

Can I include blank lines into the file when using YamlDotNet

Is there a way for me to include empty lines into the parsed YAML file using YamlDotNet? What I have currently when I parse a file like this: node1: "1.0" node2: "some text" node3: "string" I end up with this as the result: node1: "1.0" node2:…
5
votes
1 answer

YamDocument to text representation end with 3 dots

When I do : var root = new YamlMappingNode(); var doc = new YamlDocument(root); root.Add("one", "two"); var stream = new YamlStream(doc); var buffer = new StringBuilder(); using (var writer = new StringWriter(buffer)) { stream.Save(writer,…
Dragouf
  • 4,676
  • 4
  • 48
  • 55
5
votes
1 answer

YamlDotNet deserialize integer as numeric not as string

I need to convert a yaml file to json format for validating it against a json schema. So I use yamldotnet to read the yaml file and json.net to serialize it into a string in json format. Unfortunately, after that, all numeric values are converted to…
x y
  • 911
  • 9
  • 27
5
votes
1 answer

How to deserialize a YamlNode in YamlDotNet?

I have an application where I read arbitrary Yaml files whose structure I don't know in advance. I found the YamlStream and other YamlNode implementations useful, as they allow me to traverse the whole Yaml file. However, at some point I have a…
Daniel A.A. Pelsmaeker
  • 47,471
  • 20
  • 111
  • 157
5
votes
2 answers

Trivial deserialization failing with YamlDotNet

What can possible go wrong with this: public void Main() { var input = new StringReader(Document); var deserializer = new Deserializer(namingConvention: new CamelCaseNamingConvention()); var p =…
RalfW
  • 121
  • 4
5
votes
1 answer

YamlDotNet and custom types

I am discovering yaml and yamldotnet. Sorry if this is a pretty basic question: does it make any sense to define user-defined types in yaml using the single exclamation mark such as: red: !color { red: 255, green: 0, blue: 0 } How is this…
BigONotation
  • 4,406
  • 5
  • 43
  • 72
4
votes
0 answers

How to preserve the comments when parsing yaml stream in C#?

I am using YamlDotNet for reading and writing yamls. The content of the yaml file is first loaded into YamlStream and the document is processed and modified. After the document is processed, the content is written back to the file. During this…
4
votes
2 answers

Merging YAML in C#

I want to merge two YAML files into one, in such a way that it would avoid duplicates and merge the attributes. As an example, having two yaml files as presented below: yaml1: first_name: "John" last_name: "Smith" enabled: false roles: -…
Lucas Coelho
  • 583
  • 6
  • 11
4
votes
2 answers

Deserializing YAML using YamlDotNet when the root node of each object is named using it's ID?

I'm using C# and I have a YAML file I want to deserialize. I've looked at using YamlDotNet, and it looks like it's pretty decent, but I can't find how to handle this situation. The YAML text I am working with has the following format: 1: id: 1 …
user310988
4
votes
1 answer

How to Serialize and Deserialize a Type class object in C# into YAML?

I have a requirement where I have to serialize the following type hierarchy into YAML var Variable1 = new { Name = "Variable1", Type = typeof(Int32), OverWrite = true, Value = 10 }; var Variable2 = new { Name = "Variable1", …
starklord
  • 291
  • 2
  • 6
  • 16
4
votes
2 answers

Error deserializing yaml with yamldotnet

I am playing a bit with yaml and YamlDotNet But I have a problem deserializing some it seems very easy to do. This is my yaml file: --- # Folders to secure (with recursive content) folders2Secure: - .git - .vs folders2Delete: - packages -…
ferpega
  • 3,182
  • 7
  • 45
  • 65
4
votes
1 answer

YamlDotNet generate comments during POCO serialization

Is there any way to generate comments during serialization? I serialize some objects that I would like to decorate with comments.
Tomasz Plonka
  • 285
  • 4
  • 12
4
votes
1 answer

YamlDotNet deserialization throwing exception when YAML document has a field not in type

Does YamlDotNet support deserializing a document where there are fields in the document that do not map to a field in the resulting object? For example: Given a type: public class Foo { public string AField { get; set; } } If I use YamlDotNet's…
cregbrad
  • 100
  • 1
  • 5
4
votes
1 answer

Does C# YamlDotNet library support the merge key?

I have a problem with C# YamlDotNet library http://www.aaubry.net/page/YamlDotNet Do you know if the library does support the 'Merge Key' ? http://yaml.org/type/merge.html This does not seem to work for me. In other libraries, like PyYaml the merge…
Pavel
  • 88
  • 6
3
votes
1 answer

Why can I not deserialize YAML into a record?

I am using YamlDotNet and I wanted to use records for my deserialized YAML. However, I get an error like this when I try to do so: Unhandled exception. (Line: 2, Col: 3, Idx: 9) - (Line: 2, Col: 3, Idx: 9): Exception during deserialization From…
BlueStaggo
  • 171
  • 1
  • 12
1
2
3
12 13