ndjson-generate-schema
v1.0.0
Published
Effortlessly convert your NDJSON data to a JSON Schema.
Downloads
7
Maintainers
Readme
ndjson-generate-schema
Effortlessly convert your NDJSON data to a JSON Schema.
- Powered by:
generate-schema
Installation
$ npm install --save ndjson-generate-schema
# Or to use the CLI globally
$ npm install --global ndjson-generate-schema
Usage
Given an NDJSON file dogs.db
:
{"id":1,"name":"Buddy","breed":"Boston Terrier"}
{"id":2,"name":"Charley"}
CLI
$ ndjson-generate-schema
Effortlessly convert your NDJSON data to a JSON Schema.
Usage
$ ndjson-generate-schema <title> <file> [outfile]
Inputs
title Required, Title of Schema
file Required, NDJSON file to read
outfile Optional, filename to write Schema out to
Module
const path = require('path');
const ndjsonGenerateSchema = require('ndjson-generate-schema');
ndjsonGenerateSchema('Dogs', path.resolve(__dirname, 'dogs.db')).then(
schema => {
console.log(schema);
/*
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Dogs Set",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "number"
},
"name": {
"type": "string"
},
"breed": {
"type": "string"
}
},
"required": [
"id",
"name"
],
"title": "Dogs"
}
}
*/
}
);
API
ndjsonGenerateSchema(title, file)
title
Required
:String
the title of the Schema
file
Required
:String
the NDJSON file to read
License
ISC © Buster Collings