Read the body of an api which is JSON

Expanding on @NobbZ response, in your MyData type you need to make the fields start with capital letters like so:

type MyData struct {
  GrantType string json:"grant_type"
  Username string json:"username"
  Password string json:"password"
}

The encoding/json package will not fill in fields that are not exported.

2 Likes