Simple JSON to Go struct converter.
Parses JSON input and generates Go struct definitions with JSON tags.
- Parses valid JSON and generates idiomatic Go structs.
- Adds appropriate
jsontags to struct fields. - Supports optional flags:
- 📦 Custom package name
- 🧱 Custom struct name
- 💾 Output to
.gofile
go install github.com/chaewonkong/json-togo/cmd/[email protected]jtg [flags] < input.json| Flag | Shorthand | Description | Default |
|---|---|---|---|
--package |
-p |
Package name in the generated file | main |
--struct |
-s |
Name of the root struct | Data |
--output |
-o |
Path to output .go file |
${packageName}.go |
jtg -p user -s UserProfile -o user_profile.go < user.jsonGenerates a model.go file with contents like:
(in user_profile.go)
package user
type UserProfile struct {
// ...
}