summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/read-package-json/node_modules/json-parse-helpfulerror/README.md
blob: ffad93584b19d4403c5d69f6bb86bd99bcfe4530 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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

```js
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