jflect

command module
v0.0.0-...-13c4f30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2016 License: BSD-3-Clause Imports: 11 Imported by: 0

README

#+TITLE: Jflect

Takes JSON from stdin and outputs go structs to stdout.

* Documentation
[[http:godoc.org/github.com/str1ngs/jflect][godoc.org]]

Documentation

Overview

Jflect takes JSON from stdin and outputs go structs to stdout.

Installing

go get github.com/str1ngs/jflect

Examples

Web service:

curl https://api.github.com/users/str1ngs | jflect -s GithubUser

Output:

 type GitHubUser struct {
	 AvatarUrl   string `json:"avatar_url"`
	 Bio         string `json:"bio"`
	 CreatedAt   string `json:"created_at"`
	 Followers   int    `json:"followers"`
	 Following   int    `json:"following"`
	 GravatarId  string `json:"gravatar_id"`
	 Hireable    bool   `json:"hireable"`
	 HtmlUrl     string `json:"html_url"`
	 Id          int    `json:"id"`
	 Location    string `json:"location"`
	 Login       string `json:"login"`
	 Name        string `json:"name"`
	 PublicGists int    `json:"public_gists"`
	 PublicRepos int    `json:"public_repos"`
	 Type        string `json:"type"`
	 Url         string `json:"url"`
 }

From file:

jflect < foo.json

Saving is just a matter of redirecting stdout to a file.

jflect < foo.json > foo.go

curl https://api.github.com/users/str1ngs | jflect -s GihubUser > gituser.go

Notes

Jflect is primarily designed to fast prototype go structs. Its not intended for automation. It does handle nested JSON objects. But does not currently handle arbitrary JSON arrays.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL