flatten Map on golang
将嵌套map展开
func flattenMap(m map[string]any, prefix string, result map[string]any) {
for k, v := range m {
key := k
if prefix != "" {
key = prefix + "_" + k
}
switch value := v.(type) {
case map[string]any:
flattenMap(value, key, result)
default:
result[key] = v
}
}
}