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
1 answer

How to only serialize a special property's value to json

YamlDotNet can deserialize a yaml document which contain json. Suppose there is a yaml document as input like below. fieldA: a fieldB: - { "subFieldA": "a1","subFieldB": "b1" } - { "subFieldA": "a2","subFieldB": "b2" } Then, I deserialize it…
Zalasento
  • 1
  • 2
0
votes
1 answer

Getting dynamic list entries from a YAML

My input YAML looks like menu: - 'key one': 'first' - 'key two': 'second' so quite simple. The sub-keys for menu are arbitrary values so there can be anykey:anyvalue. Now I'm using YamlReader to get hold of these menu entries in a way that I…
qwerty_so
  • 35,448
  • 8
  • 62
  • 86
0
votes
1 answer

c# usage of list in yaml - error in serialization

I'am able to deserialize the yaml file, consult and change the values. Due to an requirement, I have to use the minus(-) symbol in front of the variables NAME, VERSION, ... The file test.yaml PlatForm: windows Version: 10 # Software…
Mário Cera
  • 25
  • 1
  • 5
0
votes
1 answer

YamlDotNet change property name according to value

I am trying to format the name of property of an object according to value I am getting in the output of my yaml file. I am using yamldotnet library. Below are my classes State.cs public class State { public string name { get; set; } …
Priom Biswas
  • 85
  • 2
  • 12
0
votes
1 answer

How do you deserialize static properties with YamlDotNet?

I'm having trouble deserializing yaml into static properties. When I try, I get the exception System.Runtime.Serialization.SerializationException: Property 'Test' not found on type 'Program+Config'. This seems weird to me because I was successfully…
greenjaed
  • 589
  • 8
  • 20
0
votes
1 answer

How to deserialize YAML with YAMLDotNet?

I want to deserialize this YAML with YAMLDotNet. It have sequence and nested mapping. data.yml people: - name: "John" age: 20 - name: "Michael" age: 21 - name: "William" age: 22 network: address: "192.168.1.1" port: 1234 …
ken
  • 65
  • 8
0
votes
1 answer

Is there a way to suppress single quotes in YamlScalarNode output?

Consider this simple program: using System; using YamlDotNet.RepresentationModel; namespace TestYamlNode { class Program { static void Main(string[] args) { var scalarNode = new YamlScalarNode("!yada"); …
TimMay
  • 1
  • 2
0
votes
0 answers

YamlDotNet linter validation when importing

I am importing a yaml file from my system directory. I want to validate for linter issues before Deserializing the yaml. Is there any nuget which i can use to perform the lint validation?? Does YamlDotNet provide a lint validator
Vinay
  • 259
  • 4
  • 19
0
votes
1 answer

Why doesn't YamlDotNet serialize private fields of the class?

I tried to find the answer on the Internet, but without success. Instead, several times in different posts I've met the phrase that “private fields … will never be serialized”. So I guess this is not a bug but a philosophy. I do not understand this,…
Ilia
  • 425
  • 2
  • 10
0
votes
1 answer

Deserialize a nested dictionary

I would like to convert a YAML document to an object graph using YamlDotNet deserializer. Below is a sample of yhe YAML file. desks: - A5 - A6 - A7 - A8 - ... employees: - E00 - E10 - E20 - ... schedule: 0: E00: A0 E10:…
pp492
  • 511
  • 1
  • 3
  • 12
0
votes
1 answer

Set name of key/class using YamlDotNet or SharpYaml

I'm trying to (de)serialize following YAML using YamlDotNet or SharpYaml: network: IF1: gateway4: 10.1.0.1 addresses: - 10.1.0.10/24 - 10.1.0.20/24 IF2: gateway4: 10.2.0.1 addresses: -…
MrCalvin
  • 1,675
  • 1
  • 19
  • 27
0
votes
1 answer

c# How to serialize DateTime using YamlDotNet so that it can be deserialized?

In .net Framework 4.8, am trying to serialize via YamlDotNet an object that contains a DateTime field, usually created via a DateTime.Now call. I use a custom serializer for that object, seralizing with the following as the key's value. This…
Laikar
  • 333
  • 1
  • 3
  • 9
0
votes
0 answers

How to Convert Object to YAML using YamlDotnet

public class UserInputFile { public Action[] actions { get; set; } } public class Action { public Action1[] action1 { get; set; } } public class Action1 { …
beginner
  • 39
  • 7
0
votes
1 answer

How can I deserialize a Yaml object containing strings into a List?

I created a Yaml with filenames, so I can make my program check if every file of the list exists. I haven"t done much with yaml yet, and the documentations don't really help me. This is my Yaml (It's pretty small): DLLs: - Filename1 -…
DudeWhoWantsToLearn
  • 751
  • 2
  • 10
  • 29
0
votes
1 answer

How to enable parsing yaml using yamldotnet which accepts both list and keyvalue pairs under same name?

I have a yaml where both of the following formats are acceptable - args: buildno: 1 gitcommithash: cdc3b19 And args: - buildno=1 - gitcommithash=cdc3b19 With current YamlDotnet configuration, [YamlMember(Alias =…
Pratik
  • 695
  • 2
  • 11
  • 29