HckApm/node_modules/json-parse-helpfulerror
minicx 99e5f883a3 second commit 2023-12-23 14:56:27 +03:00
..
test second commit 2023-12-23 14:56:27 +03:00
.editorconfig second commit 2023-12-23 14:56:27 +03:00
.editorconfig~ second commit 2023-12-23 14:56:27 +03:00
.npmignore second commit 2023-12-23 14:56:27 +03:00
LICENSE second commit 2023-12-23 14:56:27 +03:00
README.md second commit 2023-12-23 14:56:27 +03:00
index.js second commit 2023-12-23 14:56:27 +03:00
index.js~ second commit 2023-12-23 14:56:27 +03:00
package.json second commit 2023-12-23 14:56:27 +03:00

README.md

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