@yp/json2schema

1.0.1 • Public • Published

@yp/json2schema

Transform JSON Object to JSON Schema Version 7, Based on JSON Schema draft-07

将 json 转换成 jsonchema 规则,基于 jsonSchema 草案 7的语法规则

Installation

$ npm install @yp/json2schema

Usage

convert json

const convert = require('@yp/json2schema');
const data = {
  name: 'test',
};
let convertResult = convert(data);

convert jsonString (support jsonString with comment)

const convert = require('@yp/json2schema');
const jsonString = `{
    // Rainbows
    "unicorn": /* ❤ */ "cake" // comment
}`;
let convertResult = convert(jsonString, { isJsonString: true });

Test

npm run test

TODO

Take the comments out of jsonString and put it into jsonschema as description of keys

支持从 json 的字符串形式中,取出字段对应的注释,并放在 jsonSchema 的字段描述中

Dependencies (8)

Dev Dependencies (2)

Package Sidebar

Install

npm i @yp/json2schema

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

20 kB

Total Files

14

Last publish

Collaborators

  • njueyupeng