Converts JSON Schema definitions into TypeScript/JavaScript decoder expressions using the decoders.cc library. The package generates source code strings for decoding runtime values according to schema specifications. Version 0.2.6 supports JSON Schema drafts and integrates with the decoders runtime via optional utility library. Key differentiators: CLI and programmatic API, synchronous and asynchronous conversion functions, support for $ref resolution and namespace prefixes. Ideal for projects that already use the decoders library for runtime validation.
npm install json-schema-to-decodersNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates converting an object schema to decoder code with namespace prefixes and lib references.
Ensure 'decoders' is listed in your dependencies (it is a peer dependency).
Upgrade to >=0.2.0 and use the new Converter class with convertSchema(schema, options) signature.
Import the lib: import * as L from 'json-schema-to-decoders/decoders'; and pass nsLib: 'L.' in options.
After generation, compile the code with TypeScript or run a linter to catch errors.
Use default import: import converter from 'json-schema-to-decoders'; then converter.convertSchema(...)
Run: npm install decoders
Add a resolveRefPointer option to convertSchema, e.g., resolveRefPointer: (ref) => ref.split('/').pop()