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

YamlDotNet: Deserialize tag mapped values using parameterless constructor

YamlDotNet seems to deserialize an array of tag mapped values as nulls instead of using the default construction for each class. Is there any possibility to create instances using the default constructor instead of creating an array of null values?…
Haapavuo
  • 336
  • 2
  • 5
0
votes
0 answers

How to deserialize unknown members with YamlDotNet

This code does not work because YamlDotNet.Core.YamlException: 'Property 'unknown1' not found. How do I configure this correctly (if it is possible at all) using System.Runtime.Serialization; using YamlDotNet.RepresentationModel; using…
Kux
  • 1,362
  • 1
  • 16
  • 31
0
votes
0 answers

YamlScalarNode distinguish between Key and Value

I want to use YamlDotNet to go through all keys (but not their values) of a YAML document and check the key for a pattern. My code looks like this: foreach (var node in yaml.Documents.Single().RootNode.AllNodes) { if(node is YamlScalarNode…
D.R.
  • 20,268
  • 21
  • 102
  • 205
0
votes
0 answers

YamlDotNet how to deserialize a string with a new line

I'm trying to deserialize a string with new line separators in it. This post suggested using > or |, but when I add these in my yml file I get the following error: While scanning a block scalar, did not find expected comment or line break. My yml…
0
votes
0 answers

how to serialize dynamic json object with yamldotnet

i'm trying to creating yaml file from json using with YamlDotNet library, but i need to use dynamic object because i don't know what type of object they will send me, I created base class for serialization like this: public class plugins { …
0
votes
1 answer

How to make space indentation and blank row space in yaml file with c#

I'm new in using yaml files, and after searched in the web I didn't found a solution yet. I generate a yaml files and I want to make some indentations like this examples: My currrent output: fields: - name: tx_trig description: Indicates the…
Orionlk
  • 278
  • 2
  • 3
  • 17
0
votes
1 answer

yamldotnet added 0x0d in desktop application but not in xamarin android

I need help for my code, i will try to generate license file in cross-platform with yamldotnet but output different then desktop, it's removed 0x0D in xamarin android, i need to keep it 0x0D. Code for generating license: public void…
Freedom
  • 11
  • 3
0
votes
0 answers

Serialise specific properties with YamlDotNet

I'm using YamlDotNet. public class Parent { public int Foo { get; set; } public bool Bar { get; set; } } public class Child { public Parent Parent { get; set; } public string Baz { get; set; } public int Qux { get; set; } …
lonix
  • 14,255
  • 23
  • 85
  • 176
0
votes
0 answers

How to serialize / deserialize deeply nested nodes with YamlDotNet?

I'm trying to create / read a MongoDB configuration file through C#. The format is YAML and some nodes are deeply nested like this: storage.wiredTiger.engineConfig.cacheSizeGB : 5 From the getting started documentation, I figured I should create…
Eric
  • 19,525
  • 19
  • 84
  • 147
0
votes
1 answer

Hide specific root object during yaml serialization and show only it's children properties in yaml

I am using one object model public class MainModel { public FirstChildModel firstChild { get; set; } public SecondChildModel secondChild { get; set; } } public class FirstChildModel { public string firstProp { get; set; } public string…
0
votes
1 answer

How to signal YamlDotNet to serialize byte[] as !!binary type in .NET 5 (previous answer is not working)

In question YamlDotNet !!binary type the answer provided by Antoine Aubry and the example in A fully working example can be tried here do not work with Version="11.2.1". Is there any way to add a decorator in object properties or an alternative…
0
votes
1 answer

Remove specific field of yaml file using YamlDotNet

I'm developing an application which reads a yaml file. Let's say the yaml file has the following content: field1: 'test1' field2: 'test2' field3: 'test3' So I want to remove only the filed2 as so the new yaml file would be: field1: 'test1' field3:…
Samuel
  • 111
  • 1
  • 10
0
votes
1 answer

Nested string to class deserialization using YamlDotNet

I need to be able to dynamically deserialize strings (as properties) into classes during runtime. I also need to be able to do this in a way that supports nesting. Example - Turret which shoots exploding bullets Turret.yaml Type: Turret Name:…
0
votes
0 answers

Security implications of deserializing arbitray objects from YAML with yamldotnet

I'm currently evaluating this library from a security perspective. Since YAML can be used to serialize objects, I was wondering if the defaults provided by the parser are set such that deserialization of arbitrary objects is prevented. Putting it…
bt-nia
  • 1
0
votes
0 answers

YamlDotNet: Deserialize object to string with line separator between each object

I'm using the following code to deserialize and serialize my object var deserializer = new DeserializerBuilder().WithTagMapping("str", typeof(string)).Build(); var baseObject = deserializer.Deserialize
Hhry
  • 823
  • 1
  • 8
  • 19