durable-json-lint
raw JSON → 0.0.3 verified Fri May 01 auth: no javascript abandoned
A Json Lint library (v0.0.3, last updated in 2012) that parses and partially corrects dirty JSON without crashing. It can fix common errors like single quotes, hex numbers, and function calls, and returns corrected JSON alongside error details. Unlike most JSON linters, it continues parsing after errors and substitutes invalid constructs with null. Written in CoffeeScript, runs on Node >=0.4.0 and browsers. Low release cadence and minimal maintenance since 2013.
Common errors
error Error: Cannot find module 'coffee-script' ↓
cause Package's require may attempt to load CoffeeScript at runtime.
fix
Install coffee-script: npm install coffee-script
error TypeError: durableJsonLint is not a function ↓
cause Incorrect import: using named import instead of default.
fix
Use import durableJsonLint from 'durable-json-lint' or const durableJsonLint = require('durable-json-lint')
error Uncaught ReferenceError: require is not defined ↓
cause Using CommonJS require in ESM environment without bundler.
fix
Use import syntax or a bundler like webpack.
Warnings
deprecated Package is largely unmaintained since 2013; may not work with modern Node versions beyond 0.4.x. ↓
fix Consider using a maintained JSON linter like jsonlint or ajv.
gotcha Error status 'crash' indicates parser completely failed; no JSON returned. ↓
fix Wrap call in try-catch to handle crashes; check result.json for null.
gotcha The library substitutes invalid constructs with null without warning in corrected output. ↓
fix Always inspect errors array to understand substitutions.
breaking Package uses CoffeeScript; Node.js may require a CoffeeScript runtime to require if compiled .js missing. ↓
fix Use npm 1.x or precompile; on modern Node, install coffee-script globally or use an alternative.
gotcha Error descriptions may be humorous or sarcastic, not suitable for production error messages. ↓
fix Do not present user-facing errors directly.
Install
npm install durable-json-lint yarn add durable-json-lint pnpm add durable-json-lint Imports
- default wrong
const durableJsonLint = require('durable-json-lint')correctimport durableJsonLint from 'durable-json-lint' - default wrong
import { durableJsonLint } from 'durable-json-lint'correctconst durableJsonLint = require('durable-json-lint') - TypeScript types wrong
No type definitions existcorrectimport durableJsonLint from 'durable-json-lint' // then declare type manually
Quickstart
import durableJsonLint from 'durable-json-lint';
const result = durableJsonLint(`{name:"value", 'array':[call(), 0x11]}`);
console.log('Corrected JSON:', result.json);
console.log('Errors:', JSON.stringify(result.errors, null, 2));