@
wayn3h0 刚看官方博客
http://blog.golang.org/json-and-go ,里面这个例子跟我之前想描述的差不多:
f = map[string]interface{}{
"Name": "Wednesday",
"Age": 6,
"Parents": []interface{}{
"Gomez",
"Morticia",
},
}
m := f.(map[string]interface{})
for k, v := range m { //每次都这样搞一下
switch vv := v.(type) {
case string:
fmt.Println(k, "is string", vv)
case int:
fmt.Println(k, "is int", vv)
case []interface{}:
fmt.Println(k, "is an array:")
for i, u := range vv {
fmt.Println(i, u)
}
default:
fmt.Println(k, "is of a type I don't know how to handle")
}
}