Skip to content

chaewonkong/json-togo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 JSON TOGO

Simple JSON to Go struct converter.

Parses JSON input and generates Go struct definitions with JSON tags.


✨ Features

  • Parses valid JSON and generates idiomatic Go structs.
  • Adds appropriate json tags to struct fields.
  • Supports optional flags:
    • 📦 Custom package name
    • 🧱 Custom struct name
    • 💾 Output to .go file

📦 Installation

go install github.com/chaewonkong/json-togo/cmd/[email protected]

🛠 Usage

jtg [flags] < input.json

🔸 With Custom Flags

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

Example Usage

jtg -p user -s UserProfile -o user_profile.go < user.json

Generates a model.go file with contents like:

(in user_profile.go)

package user

type UserProfile struct {
    // ...
}

About

Simple JSON to Go struct converter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages