I have a complex string in json format which i want to convert to a map in golang. Let's say the string is
species :{
"type" : "human"
"age" : "23"
"attributes" : {
"height" : "182"
"weight" : "160"
"contact" : {
"address" : ########
"phone" : #########
}
}
}
how do i parse it such that map[attributes] is a again a map[string]interface and so on ?
You can use a map[string]interface{}, for example:
species := make(map[string]interface{})
if err := json.Unmarshal([]byte(jsonStr), &species); err != nil {
// deal with error
}