Pibd-21_Alekseev_I.S._Inter.../IP/node_modules/json-parse-helpfulerror
VanyaAlekseev c91124ead4 lab3
2023-12-21 21:08:22 +04:00
..
test lab3 2023-12-21 21:08:22 +04:00
.editorconfig lab3 2023-12-21 21:08:22 +04:00
.editorconfig~ lab3 2023-12-21 21:08:22 +04:00
.npmignore lab3 2023-12-21 21:08:22 +04:00
index.js lab3 2023-12-21 21:08:22 +04:00
index.js~ lab3 2023-12-21 21:08:22 +04:00
LICENSE lab3 2023-12-21 21:08:22 +04:00
package.json lab3 2023-12-21 21:08:22 +04:00
README.md lab3 2023-12-21 21:08:22 +04:00

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