I would like to turn this string into map [string] interface {}:
result="map[Value1:TestWS Value2:00060636 Value3:TestWS Value4:PIPPO Value5:TestWS]"
the same string printed through the JSON
"result=\"map[COD_DIPENDENTE:00060636 MATRICOLA:TestWS COGNOME:CAPPONI NOMEmy:TestWS COGNOMEmy:TestWS]\"
"
I understand that it is a particular string. In reality it derives from a map [string] interface {}, but this has gone through an encryption and a decryption and the result is this.
The "result" is not fundamental.
advice??
package stackoverflow
import "strings"
func StrToMap(in string) map[string]interface{} {
res := make(map[string]interface{})
array := strings.Split(in, " ")
temp := make([]string, 2)
for _, val := range array {
temp = strings.Split(string(val), ":")
res[temp[0]] = temp[1]
}
return res
}
the above function returns an map of string to strings. It also doesn't handle the map[]
part, which you can remove by either splitting the string before passing it or simply looking into why it gets printed that way(in the original code).