Registry / devops / easy-json-schema

easy-json-schema

JSON →
library0.0.2-betajsnpmunverified

A succinct json-schema language that converts JSON objects into JSON Schema definitions. Current stable version is 0.0.2-beta. Release cadence is low, with limited updates. Key differentiators: allows inline type definitions ("string", "number") and marks required fields with a leading asterisk (*). Simplifies manual JSON Schema creation by using a compact notation. Suitable for quickly generating schemas from sample data.

npm install easy-json-schema
INSTALL
IMPORT
SIG · EASY-JSON-SCHEMA
E
easy-json-schema
devopsjavascriptv0.0.2-beta
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export (function)
✓ import ejs from 'easy-json-schema'
✗ const ejs = require('easy-json-schema')
The package does not ship TypeScript types and is CJS-only. Use import or require accordingly.
ejs function
✓ const ejs = require('easy-json-schema');
✗ import { ejs } from 'easy-json-schema';
Default export only; named import will fail.
TypeScript usage
✓ // @ts-ignore import ejs from 'easy-json-schema';
No type definitions available; use @ts-ignore or declare module.

Converts a compact JSON object into a JSON Schema using easy-json-schema.

const ejs = require('easy-json-schema'); const input = { "id": "string", "*name": "string", "arr": [{ "site": "string", "url": "string" }] }; const output = ejs(input); console.log(JSON.stringify(output, null, 2));
Debug
Known issues
gotchaNon-string type values (e.g., nested objects with type key) will be treated as full schema definitions, but the library does not validate that the 'type' field is a valid JSON Schema type.
fix
Ensure custom type strings or type objects are valid JSON Schema types supported by the library (string, number, integer, boolean, array, object).
affects: *
gotchaThe library does not handle edge cases like null values, empty arrays, or unsupported data types gracefully; may throw or produce incorrect schema.
fix
Avoid passing null or empty arrays as input; filter them beforehand.
affects: *
deprecatedPackage is in beta and has not been updated since 2017. No support for JSON Schema Draft-07 or later features (e.g., $ref, if/then/else).
fix
Consider using a more actively maintained library like ajv or jsonschema for full JSON Schema support.
affects: *
Errors
Common errors & fixes
TypeError: Cannot convert undefined or null to object
Passing null or undefined as the input to the ejs function.
fix
Ensure input is a proper JSON object or array.
Uncaught TypeError: Cannot read property 'type' of undefined
Using an empty array [] as part of the input object for array items definition.
fix
Provide at least one item example in the array, e.g., [{"site": "string"}].
ReferenceError: require is not defined
Trying to use require in an ES module context or in the browser.
fix
Use the import syntax: import ejs from 'easy-json-schema'. For browser, bundle with a bundler like webpack or use a CDN.
Upgrade
Version history
0.0.2-betalatest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
easy-json-schema — npm install easy-json-schema · libregistry