Comments (2)
You're trying to deserialize a mapping into a string which isn't going to work. If instead you did this in your while loop:
var doc = yamlDeserializer.Deserialize<List<object>>(parser);
Console.WriteLine("## Document");
foreach (Dictionary<object, object> item in doc)
{
foreach (var kvp in item)
{
Console.WriteLine("{0}: {1}", kvp.Key, kvp.Value);
}
Console.WriteLine("======");
}
It will result in:
## Document
name: Install certbot
tags: setup
community.general.snap: System.Collections.Generic.Dictionary`2[System.Object,System.Object]
======
name: Create symlink for Certbot binary
tags: setup
ansible.builtin.file: System.Collections.Generic.Dictionary`2[System.Object,System.Object]
become: true
======
name: Check if the certificate was already generated
tags: generate_cert
ansible.builtin.stat: System.Collections.Generic.Dictionary`2[System.Object,System.Object]
register: cert_fullchain_file
======
name: Generate certificate manually
tags: generate_cert
ansible.builtin.command: System.Collections.Generic.Dictionary`2[System.Object,System.Object]
when: not cert_fullchain_file.stat.exists
======
Since you're not specifying a class you'll need to reference everything as the expected datatype in the yaml, either string
, List<object>
or Dictionary<object, object>
. Where object
will generally be one of string
, List<object>
, or Dictionary<object, object>
.
from yamldotnet.
amazing, that worked! thank you for the explanation. I've created a PR that updates the error message and adds a sample based on your reply.
from yamldotnet.
Related Issues (20)
- (Documentation) Unclear how to deserialize into objects HOT 4
- How can I know what value is not property
- Set anchor tag name during serialization using YamlDotNet? HOT 4
- Getting odd hash values in keys HOT 5
- `YamlStream.Load(TextReader)` interprets an empty value as an empty string instead of null. HOT 2
- Emitter doesn't handle comments between the mapping value and key HOT 1
- An exception occurs during Deserialize DateTimeOffset HOT 4
- How to have the `INamingConvention` passed into a custom value converter? HOT 3
- Parser does not recognize quoted keys HOT 2
- Can't handle anchored lists HOT 11
- Do you think it's useful to add some F# examples along with the C# code? HOT 4
- Schema validation support HOT 10
- Unwanted conversion from a string to a numeric value HOT 1
- missing `IDeserializer object? Deserialize(string input)` method HOT 2
- How to Serialize an object with Directives, start and end marks (---, ...)? HOT 2
- How to forcefully interpret as an array with implied key HOT 3
- YamlStream.Load with JSON with emojis (even escaped) fails: "While scanning a quoted scalar, found invalid Unicode character escape code." HOT 13
- OmitDefaults doesn't work for properties of sub-objects HOT 14
- Polymorphic deserialization - Alias $example_word cannot precede anchor declaration HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yamldotnet.