jsonformer
raw JSON → 0.0.0 verified Fri May 01 auth: no javascript
jsonformer is a JSON transpiler by value or schema, currently in early development (v0.0.0). It provides a lexer and parser for a custom JSON-like language with a context-free grammar. The project aims to enable transformation of JSON structures based on either literal values or schema definitions. As a very early-stage package, it is not yet feature-complete and has no stable release cadence. The library is written in TypeScript and targets both Node.js and browser environments.
Common errors
error Cannot find module 'jsonformer' ↓
cause Package not installed or not published to npm properly.
fix
Check package.json and run
npm install jsonformer. error import jsonformer from 'jsonformer'; SyntaxError: Unexpected identifier ↓
cause Using ES module syntax in a CommonJS environment.
fix
Set type: module in package.json or use .mjs extension, or switch to require().
Warnings
gotcha Package is in early development (v0.0.0). APIs are unstable and may change without notice. ↓
fix Do not use in production. Pin to a specific version if experimenting.
breaking Transpiler functionality (schema and value) is not yet implemented as per README. ↓
fix Use only lexer and parser for now.
deprecated The package has no published releases and may be considered abandoned by some standards. ↓
fix Monitor GitHub repository for updates.
Install
npm install jsonformer yarn add jsonformer pnpm add jsonformer Imports
- jsonformer wrong
const jsonformer = require('jsonformer')correctimport jsonformer from 'jsonformer' - lexer wrong
import lexer from 'jsonformer/lexer'correctimport { lexer } from 'jsonformer' - parser wrong
const parser = require('jsonformer').parsercorrectimport { parser } from 'jsonformer'
Quickstart
import jsonformer from 'jsonformer';
const code = `{ "hello": "world" }`;
const result = jsonformer.transpile(code);
console.log(result);