Skip to content

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

Notifications You must be signed in to change notification settings

njueyupeng/json2schema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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 的字段描述中

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published