json2typebox
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

Json2Typebox

Overview

Json2Typebox is a code generation tool that transforms Json Data into TypeScript types and TypeBox type.

targets browsers and Node.js .

Install

npm install json2typebox --save

Json to typebox

function: json2typebox()

json2typebox(json, name): Promise<string>

Params

name types default description
json string undefined json data
name string 'Root' define type name

Returns

Promise<string>

Example

import json2typebox from 'json2typebox';

json2typebox(`{"id": 1, "name": "hacxy"}`, 'Root').then((code) => {
  console.log(code);
  /*
    import { Type, Static } from '@sinclair/typebox'

    export type Data = Static<typeof Data>
    export const Data = Type.Object({
      id: Type.Number(),
      name: Type.String()
    })
 */
});

Package Sidebar

Install

npm i json2typebox

Weekly Downloads

4,511

Version

0.1.0

License

MIT

Unpacked Size

3.51 kB

Total Files

5

Last publish

Collaborators

  • hacxy