Triadai / quicktype

Generate types and converters from JSON, Schema, and GraphQL

Home Page:https://quicktype.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npm version Build Status Join us in Slack

quicktype infers types from sample JSON data, then outputs strongly typed models and serializers for working with that data in your desired programming language. In short, quicktype makes it a breeze to work with JSON type-safely. For more explanation, read A first look at quicktype.

Try quicktype in your browser at app.quicktype.io.

Supported Input Languages

  • JSON
  • JSON Schema
  • GraphQL queries
  • JSON URLs

Supported Output Languages

  • C#
  • Go
  • C++
  • Java
  • TypeScript
  • Swift
  • Elm
  • JSON Schema
  • Simple Types

Setup, Build, Run

$ npm install
$ npm run build
$ script/quicktype # rebuild and run

Edit

Install Visual Studio Code, open this workspace, and install the recommended extensions:

$ code . # opens in VS Code

Live-reloading for quick feedback

When working on an output language, you'll want to view generated output as you edit. Use npm start to watch for changes and recompile and rerun quicktype for live feedback. For example, if you're developing a new renderer for fortran, you could use the following command to rebuild and reinvoke quicktype as you implement your renderer:

$ npm start -- "--lang fortran test/inputs/json/samples/bitcoin-block.json"

The command in quotes is passed to quicktype, so you can render local .json files, URLs, or add other options.

Test

quicktype has a lot of complicated test dependencies:

  • swift compiler
  • dotnetcore SDK
  • Java, Maven
  • elm tools
  • g++ C++ compiler
  • golang stack

We've assembled all of these tools in a Docker container that you build and test within:

$ script/dev
# ... Docker will build the image and start a bash shell
$ npm run test

Test only a specific fixture

$ FIXTURE=golang npm test

About

Generate types and converters from JSON, Schema, and GraphQL

https://quicktype.io

License:Apache License 2.0


Languages

Language:TypeScript 97.2%Language:Python 1.5%Language:Shell 1.1%Language:PureScript 0.1%Language:Swift 0.0%