Skip to content
get better errors
Branch: latest
Clone or download
Latest commit 0f36e75 Mar 30, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test fix(messages): More friendly messages for non-string (#1) Mar 30, 2018
.gitignore feat(init): Initial Commit Aug 15, 2017
.travis.yml
CHANGELOG.md chore(release): 1.0.2 Mar 30, 2018
ISSUE_TEMPLATE
LICENSE.md fix(license): oops. Forgot to update license.md Aug 16, 2017
PULL_REQUEST_TEMPLATE
README.md
appveyor.yml feat(init): Initial Commit Aug 15, 2017
index.js fix(messages): More friendly messages for non-string (#1) Mar 30, 2018
package-lock.json
package.json chore(release): 1.0.2 Mar 30, 2018

README.md

json-parse-better-errors npm version license Travis AppVeyor Coverage Status

json-parse-better-errors is a Node.js library for getting nicer errors out of JSON.parse(), including context and position of the parse errors.

Install

$ npm install --save json-parse-better-errors

Table of Contents

Example

const parseJson = require('json-parse-better-errors')

parseJson('"foo"')
parseJson('garbage') // more useful error message

Features

  • Like JSON.parse, but the errors are better.

Contributing

The 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 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.

All participants and maintainers in this project are expected to follow Code of Conduct, and just generally be excellent to each other.

Please refer to the Changelog for project history details, too.

Happy hacking!

API

> parse(txt, ?reviver, ?context=20)

Works just like JSON.parse, but will include a bit more information when an error happens.

You can’t perform that action at this time.