Skip to content

Conversation

DarkiT
Copy link

@DarkiT DarkiT commented Jan 21, 2025

Add support for comma-separated tag names in DecoderConfig.TagName. The decoder will try each tag name in order and use the first valid tag value found.

Example:
config := &DecoderConfig{
TagName: "mapstructure,yaml,json",
Result: &Config{},
}

This allows more flexible struct field mapping by supporting multiple tag formats while maintaining backwards compatibility with single tag name usage.

The decoder will:

  1. Try each tag name in the specified order
  2. Use the first valid tag value found
  3. Fall back to field name if no tag found
  4. Skip field if IgnoreUntaggedFields is true and no tag found

Changes:

  • Update DecoderConfig.TagName comment to document multiple tag support
  • Modify decodeStructFromMap to handle comma-separated tag names
  • Keep backwards compatibility with single tag name usage

Add support for comma-separated tag names in DecoderConfig.TagName.
The decoder will try each tag name in order and use the first valid tag value found.

Example:
  config := &DecoderConfig{
    TagName: "mapstructure,yaml,json",
    Result: &Config{},
  }

This allows more flexible struct field mapping by supporting multiple tag formats
while maintaining backwards compatibility with single tag name usage.

The decoder will:
1. Try each tag name in the specified order
2. Use the first valid tag value found
3. Fall back to field name if no tag found
4. Skip field if IgnoreUntaggedFields is true and no tag found

Changes:
- Update DecoderConfig.TagName comment to document multiple tag support
- Modify decodeStructFromMap to handle comma-separated tag names
- Keep backwards compatibility with single tag name usage
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

Successfully merging this pull request may close these issues.

1 participant