// 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 @R_502_159@:",err)
return
}
fmt.Println("m:",m)
for k,v :=range m {
fmt.Println(k,":",v)
}
}
output:
原文链接:https://www.f2er.com/go/187523.htmlm: map[IP:192.168.11.22 name:SKY] name : SKY IP : 192.168.11.22