I have the following golang code which trying to access elements on array my expectation to print bxar ,but it throw error any idea?
package main
import (
"encoding/json"
"fmt"
)
type Data struct {
Args struct {
Foo string
}
}
func main() {
in := `[{"args": {"foo": "bar"}},{"args": {"foo": "bxar"}}]}`
var d []Data
json.Unmarshal([]byte(in), &d)
fmt.Println("Foo:", d[1].Args.Foo)
//fmt.Printf("Result: %+v", d)
}