Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/tmc/json-to-struct

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/tmc/json-to-struct

  • v0.0.0-20211021184114-75b563e346cf
  • Source
  • Go
  • Socket score

Version published
Created
Source

json-to-struct

json-to-struct attempts to generate go struct definitions from json documents

Online Version Here

npmaile edits:

Changed the logic around fields that differ in arrays to allow for pointers to structs if nilable

Example

$ curl -s https://api.github.com/users/tmc | json-to-struct -name=User
package main

type User struct {
	AvatarURL         string      `json:"avatar_url"`
	Bio               interface{} `json:"bio"`
	Blog              string      `json:"blog"`
	Company           string      `json:"company"`
	CreatedAt         string      `json:"created_at"`
	Email             string      `json:"email"`
	EventsURL         string      `json:"events_url"`
	Followers         float64     `json:"followers"`
	FollowersURL      string      `json:"followers_url"`
	Following         float64     `json:"following"`
	FollowingURL      string      `json:"following_url"`
	GistsURL          string      `json:"gists_url"`
	GravatarID        string      `json:"gravatar_id"`
	Hireable          bool        `json:"hireable"`
	HtmlURL           string      `json:"html_url"`
	ID                float64     `json:"id"`
	Location          string      `json:"location"`
	Login             string      `json:"login"`
	Name              string      `json:"name"`
	OrganizationsURL  string      `json:"organizations_url"`
	PublicGists       float64     `json:"public_gists"`
	PublicRepos       float64     `json:"public_repos"`
	ReceivedEventsURL string      `json:"received_events_url"`
	ReposURL          string      `json:"repos_url"`
	StarredURL        string      `json:"starred_url"`
	SubscriptionsURL  string      `json:"subscriptions_url"`
	Type              string      `json:"type"`
	UpdatedAt         string      `json:"updated_at"`
	URL               string      `json:"url"`
}

Installation

$ go get github.com/tmc/json-to-struct

github.com/tmc/json-to-struct github.com/ChimeraCoder/gojson github.com/str1ngs/jflect

License

json-to-struct 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 json-to-struct; the GPL only applies to software which includes copies of json-to-struct itself.

FAQs

Package last updated on 21 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc