0.0.14 • Published 10 years ago

schemar v0.0.14

Weekly downloads
4
License
mit
Repository
github
Last release
10 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

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago