I need to convert json string to map. Here is my go program.
package main
import (
"encoding/json"
"fmt"
)
func main() {
str := `{
"Bangalore_City": "35_Temperature",
"NewYork_City": "31_Temperature",
"Copenhagen_City": "29_Temperature",
"hobbies" : {
"name" : "username"
}
}`
var m map[string]interface{}
json.Unmarshal([]byte(str), &m)
fmt.Println(m["hobbies"]["name"])
}
If I use this code I am getting the below error.
get.go:26:26: invalid operation: m["hobbies"]["name"] (type interface {} does not support indexing)
Please anyone help to fix this issue. Thanks in advance