// convert json to map
package main
import (
"fmt"
"encoding/json"
)
func main() {
b := []byte(`{"IP": "192.168.11.22","name": "SKY"}`)
m := make(map[string]string)
err := json.Unmarshal(b,&m)
if err != nil {
fmt.Println("Umarshal Failed:",err)
return
}
fmt.Println("m:",m)
for k,v :=range m {
fmt.Println(k,":",v)
}
}
output:
m: map[IP:192.168.11.22 name:SKY] name : SKY IP : 192.168.11.22