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

[Question] How to make unknown fields into a specific class member. #90

Open
laper32 opened this issue Nov 16, 2024 · 0 comments
Open

Comments

@laper32
Copy link

laper32 commented Nov 16, 2024

Assume we have toml text below:

field = 1
__unknown_field_1 = "__unknown_field_value"

Assume we have related class:

class Member
{
    [DataMember(Name = "field")]
    public int Field { get; set; }

    [JsonIgnore]
    public Dictionary<string, object> UnknownFields { get; set; }
}

If there exists any fields what is not exist in the class member, then it will put into UnknownFields. The expected: (I will use json to represent it.)

{
  "field": 1,
  "unknown_fields": {
    "__unknown_fields_1": "__unknown_field_value"
  }
}

Is there any way to do it? Or in other words, is Tomlyn provides somthing like [JsonExtensionData]?

The similar feature can reference from serde-rs, which can see here: serde-rs/serde#941

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

No branches or pull requests

1 participant