I have json object that consists sub object of array. how can I print particular sub object in json. here is my code
package main
import (
"encoding/json"
"fmt"
)
func main() {
//Simple Employee JSON which we will parse
empArray := `{"meta":[
{
"id": 1,
"name": "Mr. Boss",
"department": "",
"designation": "Director"
},
{
"id": 11,
"name": "Irshad",
"department": "IT",
"designation": "Product Manager"
},
{
"id": 12,
"name": "Pankaj",
"department": "IT",
"designation": "Team Lead"
}
]}`
// Declared an empty interface of type Array
var results []map[string]interface{}
// Unmarshal or Decode the JSON to the interface.
json.Unmarshal([]byte(empArray['meta']), &results)
fmt.Println(results)
}
I'm getting below error while doing soo..
./test.go:35:23: cannot convert empArray['\u0000'] (type byte) to type []byte
./test.go:35:33: invalid character literal (more than one character)
with in the empArray
array object, I wanted to print meta
object that consists array of employees. Please help me to accomplish this.