Jsonutils
Converter for JSON data to a Go struct or a Java class for GSON
Install / Use
/learn @bashtian/JsonutilsREADME
jsonutils
Converter for JSON data to a Go struct or a Java class for GSON
go get github.com/bashtian/jsonutils/cmd/jsonutil
You can print the structure of a JSON from a URL
jsonutil https://api.github.com/repos/bashtian/jsonutils
or from a file
jsonutil -f file.json
or from stdin
echo '{"some": "data"}' | jsonutil
If you want to print example data as comments, use the -x parameter
jsonutil -x https://api.github.com/repos/bashtian/jsonutils
You can also print Java code
jsonutil -j https://api.github.com/repos/bashtian/jsonutils
Example
JSON
{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"balance": 123.45,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021"
},
"phoneNumber": [
{
"type": "home",
"number": "212 555-1234",
"last_call": "2013-01-10T05:27:07Z"
},
{
"type": "fax",
"number": "646 555-4567",
"last_call": "2013-01-10T05:27:07Z"
}
],
"tags": ["music","video"]
}
Go
jsonutil -x -c=false -f Example.json
type Example struct {
Address struct {
City string `json:"city"` // New York
PostalCode string `json:"postalCode"` // 10021
State string `json:"state"` // NY
StreetAddress string `json:"streetAddress"` // 21 2nd Street
} `json:"address"`
Age int64 `json:"age"` // 25
Balance float64 `json:"balance"` // 123.45
FirstName string `json:"firstName"` // John
LastName string `json:"lastName"` // Smith
PhoneNumber []struct {
LastCall string `json:"last_call"` // 2013-01-10T05:27:07Z
Number string `json:"number"` // 212 555-1234
Type string `json:"type"` // home
} `json:"phoneNumber"`
Tags []string `json:"tags"` // music
}
jsonutils -f Example.json
type Example struct {
Address struct {
City string `json:"city"`
PostalCode int64 `json:"postalCode,string"`
State string `json:"state"`
StreetAddress string `json:"streetAddress"`
} `json:"address"`
Age int64 `json:"age"`
Balance float64 `json:"balance"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
PhoneNumber []struct {
LastCall time.Time `json:"last_call"`
Number string `json:"number"`
Type string `json:"type"`
} `json:"phoneNumber"`
Tags []string `json:"tags"`
}
Related Skills
node-connect
343.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
92.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
