Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No setter dictionary property deserialization #455

Closed
powerumc opened this issue Dec 4, 2019 · 1 comment
Closed

No setter dictionary property deserialization #455

powerumc opened this issue Dec 4, 2019 · 1 comment
Labels

Comments

@powerumc
Copy link

powerumc commented Dec 4, 2019

I have a yaml file.

---
Name: aaa
Age: 12
Props:
  "text/html": a

And I have a class.

public class YamlData
{
    public string Name { get; set; }
    public int Age { get; set; }
    public Dictionary<string, string> Props { get; } = new Dictionary<string, string>();
}

Specially, YamlData.Props dictionary has only get accessor.

For deserializing,

var deserializerBuilder = new DeserializerBuilder()
                .IgnoreUnmatchedProperties()
                .Build();

var data = deserializerBuilder.Deserialize<YamlData>(File.ReadAllText("test.yaml"));

data.Props dictionary count is zero.
if I put the set on Props property, It is well.
But I can not change the YamlData.Props in code.

How to resolve these problem?

@EdwardCooke
Copy link
Collaborator

I believe this is fixed now with no comments in over 4 years. Closing it. If you still have problems open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants