question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need help to deserialise yaml

See original GitHub issue

Hi,

Sorry this is such a basic question. I’ve been using the other dotnet k8s library and would like to switch to yours, but I’m failing at the first hurdle.

I can’t work out how to read in my .yaml files (was doing with await Yaml.LoadFromFileAsync<V1Service>(...) in KubernetesClient, which was working fine).

I’m trying things like

Deserializer deserializer = new DeserializerBuilder()
  .Build();

... deserializer.Deserialize<ServiceV1>(File.ReadAllText(...)); 

but always get exceptions like: “Property ‘selector’ not found on type ‘KubeClient.Models.ServiceSpecV1’.”

What’s the magic salt I need to read in a .yaml?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
MichaelJComptoncommented, Mar 9, 2019

Don’t know if this is best way, but I had just thrown this in to get me moving

        private T Deserialize<T>(string yaml) =>
            JsonConvert.DeserializeObject<T>(
                JsonConvert.SerializeObject(
                    yamlDeserialiser.Deserialize(new StringReader(yaml))));
0reactions
MichaelJComptoncommented, Jun 19, 2019

Hi, no probs. I’ve actually moved on, so I don’t rely on the fix anymore.

I really like the lib while I was using it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can I not deserialize YAML into a record?
1 Answer 1 · deserialize YAML to object using YamlDotNet, · serialize that object to JSON via System.Text.Json , · and finally deserialize...
Read more >
Learning to Deserialize YAML in C# with YamlDotNET
YamlDotNet provides a set of API's for both serializing and deserializing YAML files, we'll be using these to parse a tags.yml file we ......
Read more >
Understanding YAML Deserialization | by Gupta Bless - Medium
Deserialization, on the other hand, is the process of turning data from an incoming byte stream into either a network object or data...
Read more >
Learning More About YAML Deserialization
Deserialization refers to converting these byte streams back to the object form. But how can this lead to a vulnerability? The issue arises...
Read more >
Python Yaml Deserialization - HackTricks
Yaml Deserialization ... Check how the tuple isn't a raw type of data and therefore it was serialized. And the same happened with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found