Skip to content

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

@laper32

Description

@laper32

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions