This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Description
Hello
I've a config of format
type ListItem struct {
SemVersion string `mapstructure:"sem_version"`
}
type Config struct {
ListItems map[string]ListItem `mapstructure:"list_items"`
}
cfg := Config{
ListItems: map[string]ListItem{
"item-1": {SemVersion: "v1"},
"item2": {SemVersion: "v2"},
"item_3": {SemVersion: "v3"},
},
}
out := make(map[string]interface{})
if err := mapstructure.Decode(cfg, &out); err != nil {
panic(err)
}
jsonBytes, err := json.Marshal(&out)
if err != nil {
panic(err)
}
fmt.Printf(string(jsonBytes))
Output: {"list_items":{"item-1":{"SemVersion":"v1"},"item2":{"SemVersion":"v2"},"item_3":{"SemVersion":"v3"}}}
Expected: {"list_items":{"item-1":{"sem_version":"v1"},"item2":{"sem_version":"v2"},"item_3":{"sem_version":"v3"}}}
Is there any way to get the tag names in nested items too?