Json to typebox schemas
npm install json2typeboxIf you need cli tools. see json2typebox-cli.
Json2Typebox is a code generation tool that transforms Json Data into TypeBox type.
Browsers and Node.js can both be used.
``bash`
npm install json2typebox --save
`ts
import json2typebox from 'json2typebox';
await json2typebox('{"id": 1, "name": "hacxy"}', 'Root');
/*
import { Type, Static } from '@sinclair/typebox'
export type Data = Static
export const Data = Type.Object({
id: Type.Number(),
name: Type.String()
})
*/
`
function: json2typebox()
> json2typebox(json, name): Promise\<string\>
| name | types | default | description |
| :----- | :------- | :---------- | :--------------- |
| json | string | undefined | json data |name
| | string | 'Root' | define type name |
Promise\<string`\>
- json2typebox-cli: https://github.com/hacxy/json2typebox-cli
- json2ts: https://github.com/hacxy/json2ts
MIT