Golang parse a json with DYNAMIC key [duplicate]

I believe you want something like this:

type Person struct {
    Name string `json:"name"`
    Age  int    `json:"age"`
}

type Info map[string]Person

Then, after decoding this works:

fmt.Printf("%s: %d\n", info["bvu62fu6dq"].Name, info["bvu62fu6dq"].Age)

Full example: http://play.golang.org/p/FyH-cDp3Na

Leave a Comment