Skip to content

Question: Is it possible to deserialize 'extra fields' to a dictionary object? #86

Description

@Lazrius

I am wondering if it is possible to collect all the extra fields within a Toml table, that were not processed into other fields/properties, into an Dictionary on the object. Something like this:

[TomlSerializedObject(NamingConvention = TomlNamingConvention.SnakeCase)]
public partial class Character
{
    [TomlValueOnSerialized] public required string Name { get; set; }
    [TomlValueOnSerialized] public required string Model { get; set; } 
    [TomlExtraFields] public required Dictionary<string, TomlValue> ExtraData { get; set; }
}
[[Character]]
name = "Test Character"
model = "models/characters/basic_skeleton.fbx"
cool_str = "A very cool string"
cool_number = 123 

In this example, it would example ExtraData would end up with two values, cool_str and cool_number. Is this or anything like this possible?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions