schemar generate a schema from a js object
npm install schemar
var schemar= require('schemar');
schemar.parse(obj);
schemar.parse({ "name": "Alan", "hometown": "Somewhere, TX",
"kids": [{"name": "Jimmy", "age": "12"}, {"name": "Sally", "age": "4"}]})
/*
return
{
"name": "string",
"hometown": "string",
"kids": [{ "name": "string", "age": "number" }]
}
*/
return a json schema
quoting from json schema core website
JSON Schema defines the media type "application/schema+json", a JSON based format for defining the structure of JSON data. JSON Schema provides a contract for what JSON data is required for a given application and how to interact with it. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data.
schemar.jsonSchema(datas, { textThres: 20, title: 'sparta!!' })
text