https://github.com/edsonhtj/jtos
A Tool to generate golang structures based on json examples
https://github.com/edsonhtj/jtos
go golang json
Last synced: about 1 month ago
JSON representation
A Tool to generate golang structures based on json examples
- Host: GitHub
- URL: https://github.com/edsonhtj/jtos
- Owner: EdsonHTJ
- License: bsd-2-clause
- Created: 2023-09-16T03:33:31.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-27T04:29:00.000Z (over 2 years ago)
- Last Synced: 2025-12-17T11:15:42.233Z (7 months ago)
- Topics: go, golang, json
- Language: Go
- Homepage:
- Size: 2.47 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Copy code
# [jtos](https://github.com/EdsonHTJ/jtos)
`jtos` is a command-line application for processing json input files and generating the struct code for the chosen language. Currently, only Go is supported as a language generator.
## Prerequisites
- Go (version 1.21 or newer)
## Installation
Before you can use `jtos`, you need to install it. The currently only installation possible is through go install:
```
go install github.com/EdsonHTJ/jtos/cmd/jtos@latest
```
## Usage
### Basic Usage
```
jtos [path/to/input/file]
```
With the basic usage, the input file is taken from the argument, and the output file defaults to a directory and file named after the input filename without its extension. The generator defaults to "go".
### Advanced Usage
```
jtos --input="path/to/input/file" --out="path/to/output/file" --gen="generator_type"
```
- `-g, --gen string`: The generator type to use. (default "go")
- `-h, --help`: Help for jtos.
- `-o, --out string`: Path to the output directory. (default "./")
- `-p, --package string`: Name of the output package.
- `-s, --struct string`: Name of the output structure.
For example, for an input file at `/etc/lib/test.txt`, the default output will be `test/test.go`.
### Examples
```bash
jtos example.json
# Output will be in example/example.go
```
```bash
jtos --input=sample.json --out=output/path --package=samplePkg --struct=SampleStruct
# Adjusted output, package name, and struct name.
```
## Contribution
Contributions are welcome! Please create an issue or open a pull request if you have changes or improvements.