Skip to content

MCAProject/go-json-to-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON-to-Go, converts JSON to a Go struct

Based on original code in javascript from "JSON-to-Go" from Matt Holt

Translates JSON into a Go type definition.

Things to note:

  • This code 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.

Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature or change.

Building

# go build -o json-to-go main.go

Usage

  • Read JSON file:

    json-to-go sample.json
  • Read JSON file from stdin:

    json-to-go < sample.json
    cat sample.json | json-to-go

Credits

Original javascript JSON-to-Go is brought to you by Matt Holt (mholt6).

About

Go version of javascript Json-To-Go from Matt Holt

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages