• Stars
    star
    2,655
  • Rank 17,224 (Top 0.4 %)
  • Language
    Go
  • License
    GNU General Publi...
  • Created almost 12 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Automatically generate Go (golang) struct definitions from example JSON

Build Status gojson

gojson generates go struct definitions from json or yaml documents.

Example

$ curl -s https://api.github.com/repos/chimeracoder/gojson | gojson -name=Repository

package main

type Repository struct {
	ArchiveURL       string      `json:"archive_url"`
	AssigneesURL     string      `json:"assignees_url"`
	BlobsURL         string      `json:"blobs_url"`
	BranchesURL      string      `json:"branches_url"`
	CloneURL         string      `json:"clone_url"`
	CollaboratorsURL string      `json:"collaborators_url"`
	CommentsURL      string      `json:"comments_url"`
	CommitsURL       string      `json:"commits_url"`
	CompareURL       string      `json:"compare_url"`
	ContentsURL      string      `json:"contents_url"`
	ContributorsURL  string      `json:"contributors_url"`
	CreatedAt        string      `json:"created_at"`
	DefaultBranch    string      `json:"default_branch"`
	Description      string      `json:"description"`
	DownloadsURL     string      `json:"downloads_url"`
	EventsURL        string      `json:"events_url"`
	Fork             bool        `json:"fork"`
	Forks            float64     `json:"forks"`
	ForksCount       float64     `json:"forks_count"`
	ForksURL         string      `json:"forks_url"`
	FullName         string      `json:"full_name"`
	GitCommitsURL    string      `json:"git_commits_url"`
	GitRefsURL       string      `json:"git_refs_url"`
	GitTagsURL       string      `json:"git_tags_url"`
	GitURL           string      `json:"git_url"`
	HasDownloads     bool        `json:"has_downloads"`
	HasIssues        bool        `json:"has_issues"`
	HasWiki          bool        `json:"has_wiki"`
	Homepage         interface{} `json:"homepage"`
	HooksURL         string      `json:"hooks_url"`
	HtmlURL          string      `json:"html_url"`
	ID               float64     `json:"id"`
	IssueCommentURL  string      `json:"issue_comment_url"`
	IssueEventsURL   string      `json:"issue_events_url"`
	IssuesURL        string      `json:"issues_url"`
	KeysURL          string      `json:"keys_url"`
	LabelsURL        string      `json:"labels_url"`
	Language         string      `json:"language"`
	LanguagesURL     string      `json:"languages_url"`
	MasterBranch     string      `json:"master_branch"`
	MergesURL        string      `json:"merges_url"`
	MilestonesURL    string      `json:"milestones_url"`
	MirrorURL        interface{} `json:"mirror_url"`
	Name             string      `json:"name"`
	NetworkCount     float64     `json:"network_count"`
	NotificationsURL string      `json:"notifications_url"`
	OpenIssues       float64     `json:"open_issues"`
	OpenIssuesCount  float64     `json:"open_issues_count"`
	Owner            struct {
		AvatarURL         string  `json:"avatar_url"`
		EventsURL         string  `json:"events_url"`
		FollowersURL      string  `json:"followers_url"`
		FollowingURL      string  `json:"following_url"`
		GistsURL          string  `json:"gists_url"`
		GravatarID        string  `json:"gravatar_id"`
		HtmlURL           string  `json:"html_url"`
		ID                float64 `json:"id"`
		Login             string  `json:"login"`
		OrganizationsURL  string  `json:"organizations_url"`
		ReceivedEventsURL string  `json:"received_events_url"`
		ReposURL          string  `json:"repos_url"`
		SiteAdmin         bool    `json:"site_admin"`
		StarredURL        string  `json:"starred_url"`
		SubscriptionsURL  string  `json:"subscriptions_url"`
		Type              string  `json:"type"`
		URL               string  `json:"url"`
	} `json:"owner"`
	Private         bool    `json:"private"`
	PullsURL        string  `json:"pulls_url"`
	PushedAt        string  `json:"pushed_at"`
	Size            float64 `json:"size"`
	SshURL          string  `json:"ssh_url"`
	StargazersURL   string  `json:"stargazers_url"`
	StatusesURL     string  `json:"statuses_url"`
	SubscribersURL  string  `json:"subscribers_url"`
	SubscriptionURL string  `json:"subscription_url"`
	SvnURL          string  `json:"svn_url"`
	TagsURL         string  `json:"tags_url"`
	TeamsURL        string  `json:"teams_url"`
	TreesURL        string  `json:"trees_url"`
	UpdatedAt       string  `json:"updated_at"`
	URL             string  `json:"url"`
	Watchers        float64 `json:"watchers"`
	WatchersCount   float64 `json:"watchers_count"`
}

CLI Installation

$ go get github.com/ChimeraCoder/gojson/gojson

Assuming $GOPATH/bin is in your PATH, you can now invoke gojson directly.

API Installation

$ go get github.com/ChimeraCoder/gojson/gojson

Development

$ git clone https://github.com/ChimeraCoder/gojson.git
$ cd gojson
$ go test

Building CLI

$ go build -o _build/gojson ./gojson

Installing CLI

$ go install ./gojson

Formatting

$ gofmt -w -e -s -l .

Related Work

github.com/str1ngs/jflect

License

gojson is free software distributed under Version 3 of the GNU Public License.

As of the time of writing, this is the same license used for gcc (and therefore gccgo), so it is unlikely to restrict use in any way. Note that the GPL does not extend to any output generated by gojson; the GPL only applies to software which includes copies of gojson itself.

More Repositories

1

anaconda

A Go client library for the Twitter 1.1 API
Go
1,143
star
2

gitgo

A Go implementation of Git functions
Go
345
star
3

koro

A Bengali (เฆฌเฆพเฆ‚เฆฒเฆพ) version of the Go compiler and toolchain
Go
80
star
4

docker-without-docker

A presentation about Docker, systemd, and containerization, given at the Recurse Center
78
star
5

go-for-pythonists

Presentation given at New York Python Meetup
75
star
6

tokenbucket

A Go implementation of the token bucket scheduling algorithm
Go
39
star
7

go-angular-jetpack

A sample webapp that uses both Go and Angular.js
Go
34
star
8

go-server-bootstrap

A simple sample Go web server with authentication (via OAuth, using Clef.io)
CSS
24
star
9

go-yo

A yo-yo for email, written in Go
Go
24
star
10

electrovim

JavaScript
19
star
11

pluto

Pluto is not a Planet
Go
19
star
12

journalctl-go

A Go client library for reading the systemd journal
Go
12
star
13

go-for-statistical-programming

A presentation given at the NYC Open Statistical Programming Meetup on 8/19/2013
Go
12
star
14

readinglevel

A Go package for determining the reading level of a passage of text
Go
9
star
15

emojibot

Go
9
star
16

goxml

Automatically generate golang struct definitions from example XML
Go
9
star
17

PySq

Python
9
star
18

goangel

A Go client library for the AngelList API
Go
9
star
19

Planet-hackNY

Planet HackNY
JavaScript
8
star
20

ncnyt

All the news that's fit to print()
Python
8
star
21

geheimschreiber

A Go implementation of the Geheimschreiber ("G-writer")
Go
8
star
22

nginx-ssl-docker

A simple Docker image for running nginx with SSL
Nginx
7
star
23

go-react-jetpack

Go
7
star
24

gopherbot

An IRC bot. Currently "gophrbot" on #hackny on Freenode.
Go
6
star
25

intro-to-scipy-and-numpy

A talk that was given on Nov. 14, 2013 at Columbia University.
6
star
26

docker-offlineimap-fastmail

A basic Docker container for running offlineimap with Fastmail
Shell
6
star
27

erowidparser

A quick and dirty parser for the Erowid archives
Go
6
star
28

docker-offlineimap

A Docker container for syncrhonizing email messages over IMAP in the Maildir format
Shell
5
star
29

mtwerk

A Go client library for Amazon Mechanical Turk. The "fun" alternative to mturk.
Go
5
star
30

terrorists-to-communists

JavaScript
5
star
31

duckduckbang

An add-on for adding touch-friendly !bang buttons to the DuckDuckGo search results page
JavaScript
4
star
32

MLang

4
star
33

docker-mediatomb

A Docker container for running Mediatomb
4
star
34

hackboston-webapp

Go
4
star
35

python-for-data-science

Presentation: "Python for Data Science"
4
star
36

InstaVote

InstaVote implements instant-runoff voting using Python
Python
4
star
37

lobbyistsfromlastnight

Python
4
star
38

hackny-masters-introduction-to-go

A talk given at the HackNY Masters conference on getting started with Go
Go
4
star
39

cs5830-lab2

Go
3
star
40

docker-hackerschool

A presentation about Docker, Ansible, and systemd given at Hacker School
3
star
41

vc-for-hackers

A presentation given to the 2013 hackNY fellows
3
star
42

veneur-docker

A vanilla Dockerfile and sample systemd unit for running Veneur
Shell
3
star
43

goimports-log-bug

Go
3
star
44

StatHomeworkHelper

Implements statistical formulas commonly referenced in homework for statistics classes
Python
3
star
45

mgo

A git mirror of labix.org/v2/mgo
Go
3
star
46

hackers-guide-to-privacy-and-security

3
star
47

PlayThatRacket

3
star
48

hackboston-scraping

Go
3
star
49

otterandjen

Go
3
star
50

FreeSeat

Seating Chart Generator
Common Lisp
3
star
51

textcorpora

A Go helper package that provides an interface for various corpora used in text analysis
Go
3
star
52

go.crypto

A git mirror of code.google.com/p/go.crypto/bcrypt
Go
3
star
53

Babar

Babar is a Ruby wrapper for the Toodledo API
Ruby
3
star
54

twitter-follower-logger

Go
3
star
55

erowidcoin

Go
2
star
56

docker-cockatrice

A Docker container for running Cockatrice, a Qt4 application
Shell
2
star
57

crypto-mathematical-and-applied

2
star
58

toodlego

A Go client library for the Toodledo API
Go
2
star
59

znc-kibana-playbooks

2
star
60

git-practices

Some basic git practices for new users to get started quickly
2
star
61

ReadabilityParser

Python
2
star
62

humble-interfaces-gophercon-india-2016

2
star
63

hacker-forum-get-going-with-go

A presentation given at the Hacker Union Hacker Forum on 2 December 2013 at the Huffington Post.
Go
2
star
64

PitAI

Go
2
star
65

Pysq-dev

Python wrapper for Foursquare
Python
2
star
66

gojson-web

An experimental port of gojson to the browser, using gopherjs
JavaScript
2
star
67

PKGBUILDS

PKGBUILD files for AUR packages on Arch Linux
Shell
2
star
68

symmetric-api-testing-goruco-2016

2
star
69

rc-webhook-server

Go
2
star
70

building-planet-hackny-in-go

A talk given on Nov 20, 2013 at Columbia University
Go
2
star
71

notifybuild

Go
2
star
72

fourthquare

A Lisp wrapper for the foursquare API
Common Lisp
2
star
73

android-tutorial

Sample application from https://developer.android.com/training/index.html
Java
2
star
74

tdigest-rust

Rust
1
star
75

recurse-dokku

Shell
1
star
76

rustphrases

Rust
1
star
77

gopkgrss

Mirror of jteeuwen/go-pkg-rss
Go
1
star
78

cs5560-hw3

Python
1
star
79

ncmpcpp-0.6-docker

A Docker image for the latest version of ncmpcpp that supports filtering
Shell
1
star
80

full-stack-go-client-slides

Part II of a workshop on developing full-stack Go applications (native web, mobile, & desktop)
Go
1
star
81

beamer-sample-presentation

1
star
82

godeckbrew

Go
1
star
83

gilt-webapp

Go
1
star
84

GOctober

JavaScript
1
star
85

prezent

Alternate themes for the go presentation tool
CSS
1
star