1.0.8 • Published 3 months ago

json-to-ts-types v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

JSON to TypeScript Type Generator

This npm package allows you to generate TypeScript type declarations from JSON data with customizable type names.

Installation

Using npm:

npm install --save-dev json-to-ts-types

npm install -g json-to-ts-types

Using yarn:

yarn add --dev package-name

yarn global add json-to-ts-types

Usage

After installing the package globally, you can use it from any directory on your system.

Run the package with the following command:

jttt inputPath outputPath typeName

Replace with the path to the input JSON file, with the desired path for the TypeScript type file to be generated, and with the name you want to assign to the TypeScript type.

Example

Suppose you have a JSON file named data.json containing the following data:

{ "name": "Robert Anthony Plant", "age": 75, "address": { "city": "West Bromwich", "country": "Great Britain" } } To generate a TypeScript type declaration for this data, run the following command:

jttt data.json types.ts LedZeppelin

This will create a TypeScript file named types.ts with the following type declaration:

export type LedZeppelin = 'name' | 'age' | 'address.city' | 'address.country';

Notes

Ensure that Node.js is installed on your system. You must have appropriate permissions to execute the script and read/write files in the specified directories.

1.0.8

3 months ago

1.0.7

3 months ago

1.0.6

3 months ago

1.0.5

3 months ago

1.0.4

3 months ago

1.0.3

3 months ago

1.0.2

3 months ago

1.0.1

3 months ago

1.0.0

3 months ago