JSON to Go

Turn a JSON sample into Go structs with json tags, ready to paste into a file.

Go
type Root struct {
	ID      int      `json:"id"`
	Name    string   `json:"name"`
	Profile Profile  `json:"profile"`
	Roles   []string `json:"roles"`
	Posts   []Posts  `json:"posts"`
}

type Profile struct {
	Bio   string `json:"bio"`
	Links Links  `json:"links"`
}

type Links struct {
	Site string `json:"site"`
}

type Posts struct {
	Title       string  `json:"title"`
	Views       int64   `json:"views"`
	PublishedAt *string `json:"published_at"`
	Draft       bool    `json:"draft"`
}

4 types: Root, Profile, Links, Posts

More in the yard