Questions tagged [yamldotnet]
YamlDotNet is a .NET library for YAML
172
questions
0
votes
0
answers
14
views
Is it possible to generate the yaml content by code
I want to use a foreach loop when constructing the yaml content as I want to empty a list of items onto the yaml. That list is not always the same length and it has 4 different content types (due to ...
0
votes
2
answers
38
views
How do I specify the date locale when Dserializing YAML using YamlDotNet?
In a YAML document, I've got a date formatted using an EN-GB locale (so 07/02/2019 is 2nd February 2019)
When I deserialize the document using YamlDotNet, it interprets this as an EN-US date so it ...
1
vote
1
answer
45
views
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(...
3
votes
0
answers
60
views
How do I create recursive custom tags in YAMLDotNet
I'm working with YAML in C#, using YamlDotNet. I've created a custom tag that will deserialize to a simple object supporting string interpolation. Let's say the tag is "!StrInterp", and ...
1
vote
1
answer
201
views
How can I apply YamlDotNet ScalarStyle.SingleQuoted to the string property within a List<string>?
I'm using YamlDotNet to serialize an object like this
using System.Collections.Generic;
using YamlDotNet.Core;
using YamlDotNet.Serialization;
public class Thing
{
[YamlMember(ScalarStyle = ...
1
vote
1
answer
359
views
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 ...
0
votes
0
answers
36
views
Why there are two methods in Anomaly detection by SrCnn | DetectEntireAnomalyBySrCnn & DetectAnomalyBySrCnn?
Why there are two methods for detecting anomaly for the same algorithm (SrCnn). From what i understand is that, DetectEntireAnomalyBySrCnn is used to detect anomaly for the entire input and the other ...
0
votes
1
answer
148
views
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 ...
1
vote
1
answer
310
views
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: ...
2
votes
1
answer
308
views
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....
0
votes
1
answer
177
views
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 ...
0
votes
0
answers
26
views
Alter a YAML Doc without creating types
I have a document that deserializes to contain a particular YamlSequenceNode. I would like to replace the children.
I call node.Children.Clear() and this removes the children. I then want to add ...
0
votes
1
answer
142
views
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 ...
0
votes
0
answers
64
views
Ignore Members that throw exceptions using YamlDotNet
Is it possible to ignore exceptions that are thrown when serializing to YAML using YamlDotNet? I am trying to serialize a large object that I have no control over and some of the members throw the &...
2
votes
1
answer
209
views
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 ...
0
votes
1
answer
124
views
Can YamlDotNet Deserialize to an dynamic object graph?
I have a large YAML document that I want to deserialize to a dynamic object (ExpandoObject). Can YamlDotNet deserialize directly to a dynamic object tree?
I can get there by going to Json first and ...
0
votes
0
answers
28
views
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 ...
0
votes
0
answers
117
views
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....
0
votes
1
answer
81
views
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":...
2
votes
2
answers
489
views
How do I parse only part of YAML using YamlDotNet?
Suppose I have the following YAML:
config_one:
name: foo
stuff: value
config_two:
name: bar
random: value
I want to selectively parse config_one into an object and I want config_two to be ...
1
vote
1
answer
166
views
How to handle cycles in object graph with yamldotnet serializers
I'm trying to use Yamldotnet library to serialize a model with circular references. Which serializer settings or data class attributes should I use to achieve this? I want to be able to serialize and ...
0
votes
1
answer
216
views
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 ...
0
votes
1
answer
275
views
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:...
1
vote
1
answer
547
views
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 ...
0
votes
1
answer
2k
views
Error deserializing yaml with yamldotnet - Property not found
I'm using C#, YamlDotNet and following the example:
How to deserialize YAML with YAMLDotNet?
But I'm getting the follow error:
Exception thrown: 'YamlDotNet.Core.YamlException' in YamlDotNet.dll
...
0
votes
1
answer
447
views
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
...
-1
votes
1
answer
157
views
Need help in deserializing unity asset bundle manifest file
I need to deserialize main Unity asset bundle manifest in order to merge them later (all in one).
How do you approach something like this :
ManifestFileVersion: 0
CRC: 4271548926
AssetBundleManifest:
...
1
vote
1
answer
35
views
How to serialize a YamlNode graph?
YamlDotNet seems to support serializing POC graphs, but I can't find an API that serializes an object graph made directly of YamlNode types. Is there a way to do this?
0
votes
1
answer
96
views
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'. ...
3
votes
1
answer
2k
views
YamlDotNet - Custom Serialization
I have a .NET class which represents a RPC method call, like this:
class MethodCall
{
public string MethodName { get; set; }
public Collection<object> Arguments { get; set; }
}
I want ...
1
vote
0
answers
821
views
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 ...
0
votes
1
answer
121
views
Why isn't content written to yaml document?
My intention is to write an array of Items in a yaml file, format should be like this:
- country: Denmark
city: Copenhagen
- country: Italy
city: Rome
So I wrote this method:
public static void ...
0
votes
1
answer
765
views
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: &...
0
votes
1
answer
144
views
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 ...
0
votes
0
answers
323
views
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 ...
1
vote
1
answer
291
views
How to add content to existing remotely located yaml file within Runspace C#
We can read yaml file within Runspace using code given in below post
How to read remote yaml file present in Azure VM from local machine using C# Runspace
But how to update existing remotely ...
0
votes
1
answer
1k
views
Reading Yamldotnet with c#
i've some problems when i'm trying to read a Yaml file using c# and need help to finish this task , how can i read a such Yaml file into variables so i can treat them .
FileConfig:
sourceFolder: /...
0
votes
1
answer
229
views
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 ...
0
votes
1
answer
553
views
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
- ...
1
vote
1
answer
214
views
How do I deserialize a cloudformation template yaml into a C# Dictionary of Strings?
I need my csharp app to read a cloudformation template yaml file (with !Sub and other functions) in order to copy the resource, as-is, into another cloudformation template yaml with a different ...
0
votes
1
answer
240
views
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: ...
0
votes
1
answer
363
views
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 ...
1
vote
1
answer
234
views
Deserialize YAML
I'm trying, what I think, a very simple operation but I can't wrap my head around the exception I'm getting. Basically it's a copy of the Samples.DeserializeObjectGraph example in YamlDotNet: https://...
2
votes
0
answers
432
views
How to force YamlDotNet to use Folded Block Scalar for all multi-line strings
With YamlDotNet I'm getting inconsistent serialization. I'm serializing with a basic serializer:
new YamlDotNet.Serialization.SerializerBuilder()
.DisableAliases()
.ConfigureDefaultValuesHandling(...
3
votes
0
answers
279
views
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 ...
1
vote
1
answer
225
views
Is it possible to remove a YamlNode from a YamlDocument
I'm looking to implement an extension method similar to this:
public static bool RemoveNode(this YamlDocument doc, YamlNode node)
{
}
Basically, I have a YamlDocument, and a YamlNode I would like ...
2
votes
1
answer
807
views
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 ...
0
votes
0
answers
223
views
How to Convert Object to YAML using YamlDotnet
public class UserInputFile
{
public Action[] actions { get; set; }
}
public class Action
{
public Action1[] action1 { get; set; }
}
...
2
votes
2
answers
422
views
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 ...