Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mholt/json-to-go
Translates JSON into a Go type in your browser instantly (original)
https://github.com/mholt/json-to-go
go golang json translates-json
Last synced: 4 days ago
JSON representation
Translates JSON into a Go type in your browser instantly (original)
- Host: GitHub
- URL: https://github.com/mholt/json-to-go
- Owner: mholt
- License: mit
- Created: 2014-01-21T18:11:13.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2024-07-31T15:59:24.000Z (6 months ago)
- Last Synced: 2024-10-29T15:05:03.443Z (3 months ago)
- Topics: go, golang, json, translates-json
- Language: JavaScript
- Homepage: https://mholt.github.io/json-to-go/
- Size: 399 KB
- Stars: 4,493
- Watchers: 55
- Forks: 473
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- favorite-link - 立即将 JSON 转换为浏览器中的 Go 类型 (原始)。
- awesome-golang-repositories - json-to-go
- awesome-list - json-to-go - Translates JSON into a Go type in your browser instantly (original). (Data Format & I/O / For Go)
- awesome-go-extra - json-to-go - 01-21T18:11:13Z|2022-06-08T22:11:43Z| (JSON / Advanced Console UIs)
- awesome-client-side - json-to-go - Translates JSON into a Go type in your browser instantly - [Try it!](https://mholt.github.io/json-to-go/) (Langages / Golang)
- my-awesome - mholt/json-to-go - json pushed_at:2024-07 star:4.5k fork:0.5k Translates JSON into a Go type in your browser instantly (original) (JavaScript)
- awesome-repositories - mholt/json-to-go - Translates JSON into a Go type in your browser instantly (original) (JavaScript)
README
[](https://mholt.github.io/json-to-go)
Translates JSON into a Go type definition. [Check it out!](http://mholt.github.io/json-to-go)
This is a sister tool to [curl-to-Go](https://mholt.github.io/curl-to-go), which converts curl commands to Go code.
Things to note:
- The script sometimes has to make some assumptions, so give the output a once-over.
- In an array of objects, it is assumed that the first object is representative of the rest of them.
- The output is indented, but not formatted. Use `go fmt`!Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature or change.
### Usage
- Read JSON file:
```sh
node json-to-go.js sample.json
```- Read JSON file from stdin:
```sh
node json-to-go.js < sample.json
cat sample.json | node json-to-go.js
```### Credits
JSON-to-Go is brought to you by Matt Holt ([mholt6](https://twitter.com/mholt6)).
The Go Gopher is originally by Renee French. This artwork is an adaptation.