Giter Site home page Giter Site logo

rmasci / json2struct Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yudppp/json2struct

0.0 1.0 0.0 42.1 MB

Translate to Golang struct from json

Home Page: https://yudppp.github.io/json2struct

License: MIT License

Go 58.26% Makefile 33.31% Euphoria 8.43%

json2struct's Introduction

json2struct

Create a go struct out of a json file. This will take either pipe from stdin or from a json file. (Todo: Perhaps copy it from clipboard???)

This is actually a rewrite of the json2struct command found in github.com/yudppp/json2struct I changed it to suit my needs. I've useed structs generated by this in many programs, some of them are in production without an issue. That being said, it's free, it's MIT licensed. If it blows up and causes major damage in any way -- well I didn't force you to use it.

::Note:: if no -o is given, output goes to stdout.

Usage:

File In / file out

json2struct -f infile.json -o outfile.go -n structname

This will output in a file. outfile.go.

Pipe in / file out

json2struct -f infile.json -n structname

Pipe in / standard out

cat somejsonfile.json | json2struct  -n structname

Get JSON from clipboard:

If you're not piping input or if -f is not used. The program will pull whats on the clipboard and use that.

  1. Copy json to your clipboard
json2struct -o outfile.go

Example:

$ json2struct -o outfile.json
$ cat outfile.json
{
type Data struct {
	Configurations []DataConfiguration `json:"configurations"`
	Version        string              `json:"version"`
}

type DataConfiguration struct {
	Args    []interface{}        `json:"args"`
	Env     DataConfigurationEnv `json:"env"`
	Mode    string               `json:"mode"`
	Name    string               `json:"name"`
	Program string               `json:"program"`
	Request string               `json:"request"`
	Type    string               `json:"type"`
}

type DataConfigurationEnv struct {
}

json2struct's People

Contributors

yudppp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.