我有以下代码:
empArray := `{"people_array":
[
{
"id": 1,
"name": "Mr. Boss",
"department": "",
"designation": "Director"
},
{
"id": 11,
"name": "Irshad",
"department": "IT",
"designation": "Product Manager"
}
]
}`
// Declared an empty interface of type Array
var results map[string]interface{}
// Unmarshal or Decode the JSON to the interface.
json.Unmarshal([]byte(empArray), &results)
fmt.Println(results["people_array"])`
结果是
[map[department: designation:Director id:1 name:Mr. Boss] map[department:IT designation:Product Manager id:11 name:Irshad]]
我需要获取每个地图的内容,并获取“名称”。 我怎么能得到它?