Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
CHANGELOG.md | D | 12-May-2024 | 1.2 KiB | 47 | 20 | |
LICENSE.md | D | 12-May-2024 | 1 KiB | 8 | 4 | |
README.md | D | 12-May-2024 | 2.1 KiB | 47 | 28 | |
index.js | D | 12-May-2024 | 1.1 KiB | 39 | 37 | |
package.json | D | 12-May-2024 | 2.3 KiB | 83 | 82 |
README.md
1# json-parse-better-errors [](https://npm.im/json-parse-better-errors) [](https://npm.im/json-parse-better-errors) [](https://travis-ci.org/zkat/json-parse-better-errors) [](https://ci.appveyor.com/project/zkat/json-parse-better-errors) [](https://coveralls.io/github/zkat/json-parse-better-errors?branch=latest) 2 3[`json-parse-better-errors`](https://github.com/zkat/json-parse-better-errors) is a Node.js library for 4getting nicer errors out of `JSON.parse()`, including context and position of the parse errors. 5 6## Install 7 8`$ npm install --save json-parse-better-errors` 9 10## Table of Contents 11 12* [Example](#example) 13* [Features](#features) 14* [Contributing](#contributing) 15* [API](#api) 16 * [`parse`](#parse) 17 18### Example 19 20```javascript 21const parseJson = require('json-parse-better-errors') 22 23parseJson('"foo"') 24parseJson('garbage') // more useful error message 25``` 26 27### Features 28 29* Like JSON.parse, but the errors are better. 30 31### Contributing 32 33The npm team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The [Contributor Guide](CONTRIBUTING.md) has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear. 34 35All participants and maintainers in this project are expected to follow [Code of Conduct](CODE_OF_CONDUCT.md), and just generally be excellent to each other. 36 37Please refer to the [Changelog](CHANGELOG.md) for project history details, too. 38 39Happy hacking! 40 41### API 42 43#### <a name="parse"></a> `> parse(txt, ?reviver, ?context=20)` 44 45Works just like `JSON.parse`, but will include a bit more information when an 46error happens. 47