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

1.0.2 • Public • Published

typeof-json

Convert json string to typescript interface

use

import { render } from 'typeof-json';
 
console.log(
  render(
    `
    {
      name: 'lili', // name
      /** age */
      age: 18,
      love: ['ball'],
      test: {
        hello: 'world'
      }
    }`,
    'RootType',
  ),
);

result

interface Test {
  hello: string;
}
 
interface RootType {
  /**
   * name
   */
  name: string;
  /**
   * age
   */
  age: number;
  love: string[];
  test: Test;
}

TodoList

  • merge same name interface
  • merge same structure to same interface
  • Custom naming rules
  • Configure whether to generate comments

Readme

Keywords

none

Package Sidebar

Install

npm i typeof-json

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

68.5 kB

Total Files

56

Last publish

Collaborators

  • wulunyi