如何在旅途中遍历地图切片?

时间:2019-06-13 19:47:35

标签: arrays go

我有以下代码:

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]]

我需要获取每个地图的内容,并获取“名称”。 我怎么能得到它?

0 个答案:

没有答案