json-to-go-cli

1.0.0 • Public • Published

Json-to-go-cli.jshttps://mholt.github.io/json-to-go/

Command line wrapper around the JSON-to-Go module which powers the https://mholt.github.io/json-to-go/ online utility for converting a json object into a Golang type definition.

Usage

Usage: json-to-go [Options] [-s/--string] <json-string> [-f/--file] <json-filepath>

Options:
  -V, --version          output the version number
  -f, --file <path>      location of file containing json to convert
  -s, --string <string>  json string to convert
  -i, --inline           Use inline type definitions
  -h, --help             output usage information

Examples

Providing a string

user@host # json-to-go -s '{"status": {"message": "All Good!"}}'
type AutoGenerated struct {
    Status struct {
        Message string `json:"message"`
    } `json:"status"`
}

Providing a file path

user@host # json-to-go -f /path/to/json-file.json '{"status": {"message": "All Good!"}}'
type AutoGenerated struct {
    Status struct {
        Message string `json:"message"`
    } `json:"status"`
}

Inline Type Definitions

user@host # json-to-go -f /path/to/json-file.json '{"status": {"message": "All Good!"}}'
type AutoGenerated struct {
    Status Status `json:"status"`
}
type Status struct {
    Message string `json:"message"`
}

Credits

Original JSON-to-Go utility/library created by Matt Holt (mholt6) which can be found here.

Command line utility created by Ricky Grassmuck.

Readme

Keywords

none

Package Sidebar

Install

npm i json-to-go-cli

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

19.8 kB

Total Files

7

Last publish

Collaborators

  • rigrassm