Generate structs from JSON definitions
A JSON-to-struct generator for Go
Because sometimes you just have to generate a struct from json.
Requirements
- Go 1.11
Install structer using the installation script by executing the following command (execute in directory with write permissions):
curl https://s3.eu-central-1.amazonaws.com/structer/dist/structer_installer.sh | bash
The installer script is available for download here.
When installed, run the structer
command from terminal:
structer
You should see the following output:
Structer is a tool for creating struct types from definitions stored as JSON.
Usage:
structer [command]
Available Commands:
help Help about any command
make Makes a struct from JSON data.
Flags:
--config string config file (default is $HOME/.structer.yaml)
-h, --help help for structer
-t, --toggle Help message for toggle
Use "structer [command] --help" for more information about a command.
To get familiar with the main command, make
, use the help option
structer help make
Makes a struct from JSON data.
Usage:
structer make [flags]
Flags:
--format string the format of the input (default "json")
-h, --help help for make
--in string path to input file or directory
--out string path to output directory (default "generated")
Global Flags:
--config string config file (default is $HOME/.structer.yaml)
Use structer make
providing the path to json file in the --in
parameter:
structer make --in <PATH_TO_JSON_FILE>
TIP
For more examples visit the Examples directory.
TIP
Download the latest release of structer for your platform.
src
archive if you’d like to build this tool form source. See [Building From Source]File name | Kind | OS | Arch | Size | Checksum |
---|---|---|---|---|---|
structer-installer.sh | Installer | - | - | 3.4KB | View |
structer_0.1.0_darwin_386 | Archive | OSX | x86 | 10.9MB | View |
structer_0.1.0_darwin_amd64 | Archive | OSX | x86-64 | 12.3MB | View |
structer_0.1.0_linux_386 | Archive | Linux | x86 | 10.9MB | View |
structer_0.1.0_linux_amd64 | Archive | Linux | x86-64 | 12.9MB | View |
structer_0.1.0_freebsd_386 | Archive | freebsd | x86 | 10.9MB | View |
structer_0.1.0_freebsd_amd64 | Archive | freebsd | x86-64 | 12.3MB | View |
structer_0.1.0_windows_386 | Archive | Windows | x86 | 10.9MB | View |
structer_0.1.0_windows_amd64 | Archive | Windows | x86-64 | 12.4MB | View |
Builds for other platforms available here.
Release 0.1.0
See release log for more information about the current and previous structer releases.
Either download the source package or clone this repository, cd into the directory where you have the source files, and execute:
make && make install
This will build and install the structer executable to your path.
That’s it. Now you can run:
structer
Makefile offers the following options:
# Start the build process, cross-building all supported platforms:
make
# Start the build process for the current platform:
make current
# Start the build process for a specific platform:
make platform darwin_amd64
# The publish option is reserved for project maintainers.
# It will publish the distributable files to the build server
# after a successful build.
make publish
# Make install assumes there's a build file waiting in the build
# directory, and tries to move it to system path:
make install
# Downloads and installs the prebuilt binary for the current platform:
make web_install
Make sure you try the Quick Start guide first. See the examples directory for more examples.
Below is a very simple one:
structer
structer help
structer make --in <PATH_TO_JSON_FILE>
TIP
TBD
structer test run
Contributions are welcome. Check Issues & Roadmap below to see how you can help with priority features, bugs,
tests or
docs.
Contribution guidelines are described in the Contributing document.
Issue tracker top:
STR-2 Enable (extendable) multiple input formats
STRU-3 TBD
Feel free to get in touch if you have a question or request in connection to this program or source repository.
Open, public communication is the prefered choice:
Private inquiries over email. Find emails in:
Licensed under the Apache License, Version 2.0. See the LICENSE file distributed with this source code for the full text license agreement.