json2struct
Generates go type struct from json struct
Installation
go get -insecure gurpscc.ddns.net/git/hellcat/json2struct
You need -insecure flag because of problems on our git server. Will be fixed after switching domain.
It will download and install json2struct to %gopath%\bin
Usage
Usage: json2struct [options] <input file>
Options:
flag |
type |
description |
defaults |
-c |
string |
Select json struct to save as a comment for something |
comment |
-h |
int |
Set json data height. Currently WIP. |
2 |
-o |
string |
Set output path |
current dir |
-p |
string |
Set package name for generated file |
main |
Accessing data
Json2struct generates functions that returns types with default values.
All functions has the same structure:
func GetYourTypeNameHereDefaults() *yourType {
// ...
// some basic stuff here
// ...
return yourTypeVariable
}
So to get data you need just to call this func and save return.
Why do I need it?
I don't know, but in my opinion:
- easier to acess default values
- save types in json format
- save some time
License
MPL 2.0