Answer the question
In order to leave comments, you need to log in
Convert Interface{} to Map?
Good evening of the day!
Tell me please. There is the following code and the following structure:
func AddToMap(decoded interface{}) (map[string]interface{}) {
v := reflect.ValueOf(decoded)
if v.Kind() == reflect.Map {
for t, key := range v.MapKeys() {
strct := v.MapIndex(key)
if key.Interface().(string) == "KeyN" {
(///////-----///////)?????
}
}
}
return UserData
}
Пример структуры:
Map["key1":"value1", map["key2"]:{"value2, ... ,valueN"}, .... , map["KeyN":[map["NeedKey"]:{"NeedValue1, NeedValue2"}]]....]
k := reflect.ValueOf(strct)
for _, values:= range k.MapKeys() {
.....
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question