λ沢.dev

lambdasawa.dev


Project maintained by lambdasawa Hosted on GitHub Pages — Theme by mattgraham

struct generator

quicktype

JSON から Go の構造体、 TypeScript の interface などを生成するコマンド。

$ curl -sSL https://httpbin.org/json | npx quicktype --lang go --just-types
type TopLevel struct {
        Slideshow Slideshow `json:"slideshow"`
}

type Slideshow struct {
        Author string  `json:"author"`
        Date   string  `json:"date"`
        Slides []Slide `json:"slides"`
        Title  string  `json:"title"`
}

type Slide struct {
        Title string   `json:"title"`
        Type  string   `json:"type"`
        Items []string `json:"items,omitempty"`
}