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
3
votes
3 answers

YamlDotNet deserialization of deeply nested dynamic structures

I have a deeply nested object model: public class CheatSheet { public string Leader { get; set; } public List
Sections { get; set; } } public class Section { public string Title { get; set; } public List
Philip Daniels
  • 994
  • 1
  • 7
  • 25
3
votes
2 answers

Is there a way to determine how POCO properties are serialized with YamlDotNet?

If I have a POCO defined in C#, can I control how the properties of that POCO are represented in YAML? For example: class A { string Name{get;set;} } I would like it to be serialized as below (lower case, essentially): a: name: value In…
iagomartinez
  • 172
  • 10
2
votes
1 answer

YamlDotNet: How do I deserialize either a Sequence or a Mapping?

There's a YAML configuration file that my application loads: sonarr: - base_url: abc1 api_key: xyz1 - base_url: abc2 api_key: xyz2 I want to change the schema for this to use a mapping (for named instances) rather than an array. Additionally, I…
void.pointer
  • 24,859
  • 31
  • 132
  • 243
2
votes
1 answer

Can YamlDotNet's IDeserializer be used as a singleton in IServiceCollection?

I'm configuring a YamlDotNet deserializer like this: static IDeserializer CreateYamlDeserializer() { var deserializer = new DeserializerBuilder() .WithNamingConvention(CamelCaseNamingConvention.Instance) .WithTypeConverter(new…
Krumelur
  • 32,180
  • 27
  • 124
  • 263
2
votes
2 answers

YamlDotNet Convert YAML to JSON in C#

I need help when trying to convert a yaml to json it is passing all the properties to string, and it does not recognize the bool or integer fields. I am using the YamlDotNet library, in c #. If anyone can help me I would appreciate it // convertir…
Jorge
  • 43
  • 6
2
votes
1 answer

How to update a property value in YamlDotNet?

I'm trying to load an existing yaml file and update some of its properties. However- I'm trying not to override the other properties. My yaml: A: a1: value1 a2: value2 Desired yaml: A: a1: value1 a2: modified I currently have the following…
Shtut
  • 1,397
  • 2
  • 14
  • 28
2
votes
1 answer

How to deserialize YAML property into a class with passed parameters?

I'm trying to achieve a functionality implemented in the game "RimWorld" with XML, using YamlDotNet. I am aware of how to deserialize basic information, like so: instanceOfDeserializer.Deserialize(someTextReaderInstance) I am trying to…
2
votes
1 answer

How to convert YAML data to a HTML table using YAMLDONET and C#?

I need to read a YAML file and then convert it to HTML file. I tried using YAMLDOTNET and C#. This is an example of the YAML file; component1: kbName : KB210006 grayVersion : 15.2.9.0013 greenVersion …
joe
  • 21
  • 1
2
votes
1 answer

Exception when deserializing yaml file to property of abstract class using YamlDotNet

Using YamlDotNet, I'm trying to deserialize a yaml file with a nested object graph into a set of custom .net types. This works if I set the tree property to a simple PopulationBasicNode, but when I use the PopulationAndNode as shown in the example,…
Ledda
  • 35
  • 6
2
votes
1 answer

YamlDotNet throwing exception when deserializing object

So, I am new to Yaml and YamlDotNet. I wrote the following code to parse a yaml file I am using for configuration of an client API... public bool TryGet(string path, out DiagnosticScannerConfig config) { var deserializer = new…
Albert
  • 33
  • 6
2
votes
2 answers

How to remove 3 dots at end of Yaml file in C#?

I'm using YamlDotNet Nuget-package to read and write a Yaml file in C#/.Net Framework. While writing yaml file, it creates 3 dots at end of file. Since these dots are optional so I don't want them. Is there a way to exclude them while creating yaml…
Sabir H.
  • 21
  • 2
2
votes
0 answers

YamlDotNet - Serialize Private Properties

By default YamlDotNet does not serialize private properties. Is it possible to serialize also private properties? In the end I would like to serialize all properties that do have the YamlMember Attribute. using System; using System.IO; using…
surrz
  • 295
  • 2
  • 11
2
votes
1 answer

Deserializing a Unity prefab/scene as nested hashtable of key/value pairs

I'm trying to write a tool that scans through our Unity (2017.4.22) prefabs and scene files to look for Monobehaviour properties that don't exist in a release build. I've created a c# console project (incorporating YamlDotNet 6.1.2), and from this…
2
votes
3 answers

Getting a YAMLDotNet/SharpYAML node using a string path (such as "category.object.parameter")

In all other YAML libraries I've used one can get a node by simply entering the path to it as a string in a get function, is there a feature like that in YAMLDotNet?
Karl Essinger
  • 113
  • 10
2
votes
1 answer

YamlDotNet: How to customize deserializer to handle same key with different type of value

config.yaml: App1: settings: redirectUrl: http://www.test.com App2: settings: redirectUrl: test: http://www.test.com prod: http://www.prod.com C# objects public class Config { public Dictionary Apps { get;…
Chang Liu
  • 61
  • 6