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

Unable to Serialize JSON to Dictionary

I have an issue with JSON serialization into a class with a dictionary property. The whole process is a bit more complex, as an input i have a YAML file that i convert into a json using YamlDotNet and NewtonSoft like so This is an example of the…
guyl
  • 2,158
  • 4
  • 32
  • 58
2
votes
0 answers

YamlDotNet Emit Default Value (not values)

I'm currently working on a project that uses YamlDotNet for object serialization. SerializerBuilder().EmitDefaults().Build() returns me a serializer which emits every property no matter if it contains the default value or not. Is there a way to…
nych
  • 31
  • 2
2
votes
0 answers

YamlDotNet - How to deserialize multiple different document which is together?

Searched online for a solution but didn't get it. Is there anyone for help! I want to deserialize following YAML documents. The problem is each document is in the different structure. Is there anyway? %YAML 1.1 %TAG !u! tag:unity3d.com,2011: ---…
Aldo
  • 76
  • 5
2
votes
1 answer

Serialize multiline string with |?

Using YamlDotNet, the following string; "blah blah blah \n blah blah blah" gets serialized as: test: >- blah blah blah blah blah blah Is it possible to have this serialized as test: | blah blah blah blah blah blah dotnet…
edeboursetty
  • 5,669
  • 2
  • 40
  • 67
2
votes
1 answer

Removing default constructor used by YamlDotNet

I have an object graph containing nodes of various types. All nodes derive from a Node class. Using YamlDotNet I've managed to serialize and deserialize the graph by providing my own implementation of IObjectFactory. The only thing left to do is to…
2
votes
0 answers

YamlDotnet does set references correct

I have a class which looks like this: public class Item { public Guid Id { get; set; } public Guid Parent { get; set; } public string Name { get; set; } } If I serialize it: var parentId = Guid.NewGuid(); var items = new…
Zebi
  • 8,682
  • 1
  • 36
  • 42
2
votes
2 answers

YamlDotNet SerializationOptions.EmitDefaults behaviour

I'm serializing an object with YamlDotNet with both reference and value types. What i'm looking to accomplish is that my integer values of zero remain in the outputted yaml, but null values would be discarded. EmitDefaults looks to discard '0' for…
Waterboy4800
  • 232
  • 2
  • 10
2
votes
1 answer

Trying to convert YAML file to hashtable using yamldotnet

Right now I am trying to convert a YAML file into a hash table, utilizing the Deserializer that is provided in the YamlDotNet library. Getting the error Excpected 'SequenceStart' got 'MappingStart'. var d = Deserializer(); var result =…
FyreeW
  • 395
  • 1
  • 5
  • 18
2
votes
1 answer

How to serialize/deserialize list with interface

I've trying to serialize and deserialize a list with an interface, the problem is that yamldotnet cannot deserialize it. I've show it to you with an example: interface IAnimal { string Name { get; } } class Cat : IAnimal { public string Name…
jmattheis
  • 10,494
  • 11
  • 46
  • 58
2
votes
1 answer

Customise serialisation of Dictionary to Yaml

I'm looking to find a clean method of customising the output from YamlDotNet serializer. I have the following POCO: public class MyClass{ public string Foo { get;set; } public Dictionary Bar { get;set; } } If I set values on it…
Fermin
  • 34,961
  • 21
  • 83
  • 129
2
votes
1 answer

How to specify alias on YamlMember in YamlDotNet?

I need to deserialize the following YAML to my custom type. YamlAlias attribute seems to be obsolete, so I replaced it with YamlMember. It fails on deserializing the following YAML with the below exception: host: properties: …
Boris Modylevsky
  • 3,029
  • 1
  • 26
  • 42
2
votes
2 answers

YamlDotNet !!binary type

I am trying to send binary data, i.e. byte arrays, using yaml. According to the yaml documentation, Yaml Binary Type, this is supported. On the Java side I use SnakeYaml and if a value of byte[] is passed, then the yaml correctly gives…
Chill
  • 77
  • 11
2
votes
1 answer

Can I read YamlDotNet mappings sequentially?

Is it possible to access the keys of a mapping in the same order they appeared in the source document? I.e. if I have this simple document: values: first: something1 second: something2 third: something3 Then I would be able to get a…
Andre
  • 637
  • 6
  • 16
2
votes
2 answers

Does YamlDotNet library support Deserialization into existing object?

Does YamlDotNet library support Deserialization into existing object rather than creation a new one? I need it because my object is created through Dependency Injection, so I prefer a way when Deserialization fill (rewrite) all properties into the…
Brains
  • 594
  • 1
  • 6
  • 18
2
votes
1 answer

Does YamlDotNet library support the document separator?

This YAML file: --- - Prisoner - Goblet - Phoenix --- - Memoirs - Snow - Ghost is deserializing by this code: var input = new StreamReader (path) var deserializer = new Deserializer(); var lis = deserializer.Deserialize >…
Brains
  • 594
  • 1
  • 6
  • 18