json-to-go-cli
Convert json string to Golang struct
How to install
git clone https://github.com/tiancheng92/json-to-go-cli.git
cd json-to-go-cli
go build
mv json-to-go-cli ~/your/PATH/directory
How to use
-
Nested
json-to-go-cli -ns '{"abc":"2021-09-15T13:22:32.768+08:00","d":1,"e":1.1,"f":12312312312312,"g":null,"h":[],"i":{"123":321}}'
output
type AutoGenerated struct { Abc time.Time `json:"abc"` D int `json:"d"` E float64 `json:"e"` F int64 `json:"f"` G interface{} `json:"g"` H []interface{} `json:"h"` I struct { Num123 int `json:"123"` } `json:"i"` }
-
Spread
json-to-go-cli -s '{"abc":"2021-09-15T13:22:32.768+08:00","d":1,"e":1.1,"f":12312312312312,"g":null,"h":[],"i":{"123":321}}'
output
type AutoGenerated struct { Abc time.Time `json:"abc"` D int `json:"d"` E float64 `json:"e"` F int64 `json:"f"` G interface{} `json:"g"` H []interface{} `json:"h"` I I `json:"i"` } type I struct { Num123 int `json:"123"` }