json-parse-helpfulerror

A drop-in replacement for JSON.parse that uses `jju` to give helpful errors

MIT 3 个版本
安装
npm install json-parse-helpfulerror
yarn add json-parse-helpfulerror
pnpm add json-parse-helpfulerror
bun add json-parse-helpfulerror
README

json-parse-helpfulerror

A drop-in replacement for JSON.parse that uses https://npmjs.org/jju to provide more useful error messages in the event of a parse error.

Example

Installation

npm i -S json-parse-helpfulerror

Use

var jph = require('json-parse-helpfulerror');

var notJSON = "{'foo': 3}";     // keys must be double-quoted in JSON

JSON.parse(notJSON);            // throws unhelpful error

jph.parse("{'foo': 3}")         // throws more helpful error: "Unexpected token '\''..."

License

MIT

版本列表
1.0.3 2015-01-04
1.0.2 2015-01-04
1.0.1 2015-01-04