JSON literal typer
There are some tools out there that will produce TypeScript Interfaces from a
given JSON structure for you. But they only give you the basic types (string
,
number
, etc.). What if there is an API where you want to get its literal
values/types?
Install
# to add to your project npm install json-literal-typer# to use command line interface npm install --global json-literal-typer
Demo
There is a live demo at https://json-literal-typer.peppnet.de
Example
Let's assume there is an API for gas stations. It will respond with data like this:
What you would get from other tools is:
Nice. But what if you could get:
CLI
npm show json-literal-typer versions --json | json-literal-typer
related or inspiring projects
- json-to-ts - Convert jsons to typescript interfaces
- json2ts - generate TypeScript interfaces from JSON
- quicktype - Generate types and converters from JSON, Schema, and GraphQL
- ts-ast-viewer - TypeScript AST viewer