Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
marhaupe committed Jan 18, 2020
1 parent 95a916c commit fa4ed05
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
At some point when dealing with JSONs in Go, you will have to write types to `json.Unmarshal` your JSONs into. Doing this by hand is not only repetitive and time consuming, but also error prone. `json2struct` saves you this work by automatically parsing the JSON and generating you the matching type definitions ready to be used.

Different to other tools, `json2struct` tries to avoid generating `interface{}` and `map[string]interface{}` as much as possible. Nonetheless it's very fast 🚀.
Unlike other tools, `json2struct` tries to avoid generating `interface{}` and `map[string]interface{}` as much as possible. Nonetheless it's very fast 🚀.

# Installation

Expand All @@ -25,34 +25,37 @@ brew install marhaupe/json2struct/json2struct

## Manually

Simply grab the latest release [binaries](https://github.com/marhaupe/json2struct/releases).
Grab the latest release [binaries](https://github.com/marhaupe/json2struct/releases).


# Usage

> json2struct [flags]
> json2struct [options]
Calling `json2struct` without flags opens a text editor. Simply input your JSON and save and exit.

![Example](.github/demo.gif)

## Flags:
## Options
You probably don't want to manually write that 1MB JSON you have to generate a struct for by hand. I mean, if you really want to, I'm not here to judge, but that's not the point. These options will make your life easier. If you miss some, feel free to open an issue.

### File
> -f, --file string: path to JSON file
```bash
json2struct -f apiResult.json
```

### String
### Generating a struct from a string
> -s, --string string: JSON string

This is basically your bread and butter thanks to pipes. Usage:
```bash
json2struct -s "$(curl "https://reqres.in/api/users?page=2")"
```
### Generating a struct from an existing file
> -f, --file string: path to JSON file
This is useful if you have a JSON file stored in your filesystem and are too lazy to use pipes. Usage:
```bash
json2struct -f input.json
```

### Benchmark
> -b, --benchmark: measure execution time
### Other options
> -b, --benchmark measure execution time
> -h, --help help for json2struct
> --version version for json2struct

0 comments on commit fa4ed05

Please sign in to comment.