0.0.14 • Published 9 years ago

schemar v0.0.14

Weekly downloads
4
License
mit
Repository
github
Last release
9 years ago

schemar

schemar generate a schema from a js object

install

npm install schemar

Api

parse

var schemar= require('schemar');
schemar.parse(obj);

example

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" }]
}
*/

jsonSchema

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.

example

schemar.jsonSchema(datas, { textThres: 20, title: 'sparta!!' })

options

  • textThres: threshold length that string will be seen as text
  • title: outer object title

types

  • string
  • number
  • boolean
  • date
  • date(format)
  • object
0.0.14

9 years ago

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago

0.0.0

9 years ago