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

Feature Request: Metadata when decoding into maps #12

Open
EronWright opened this issue Feb 13, 2024 · 0 comments
Open

Feature Request: Metadata when decoding into maps #12

EronWright opened this issue Feb 13, 2024 · 0 comments

Comments

@EronWright
Copy link

I would like to be able to decode to a map, with deep processing of the data, and collect metadata about the keys that were decoded. For example:

actual := map[string]interface{}
config := &mapstructure.DecoderConfig{
  Metadata:   &mapstructure.Metadata{},
  Result:     actual,
}
decoder, err := mapstructure.NewDecoder(config)

decoder.Decode(map[string]interface{}{
  "a": map[string]interface{}{
    "b": "value",
  },
})
assert.Equals(t,  []string{"[a]", "[a][b]"}, config.Metadata.Keys)

At the moment, the nested map (a) is simply referred to directly in the target map, and the .Metadata.Keys contains only [a].

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