# try-json-parse

> Doesn't throw an error when JSON.parse() fails, just returns undefined

Latest version **1.0.0** (published 2017-07-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install try-json-parse
pnpm add try-json-parse
yarn add try-json-parse
bun add try-json-parse
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-07-06 |
| First published | 2013-10-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Alexandru Vladutu |
| Maintainers | alessioalex |
| Keywords | err, custom, custom-error, customerror |

## Links

- npm: https://www.npmjs.com/package/try-json-parse
- Repository: https://github.com/alessioalex/try-json-parse
- Homepage: https://github.com/alessioalex/try-json-parse#readme
- Issues: https://github.com/alessioalex/try-json-parse/issues
- npm.io page: https://npm.io/package/try-json-parse

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-07-06
- 0.1.1 — 2014-06-25
- 0.1.0 — 2014-06-20
- 0.0.1 — 2013-10-20

## README

### try-json-parse

Just like `JSON.parse()`, except it returns `undefined` instead of throwing an error for invalid JSON.

### Usage

```js
var JSONparse = require('./index'),
    assert    = require('assert'),
    fs        = require('fs');

fs.readFile(__dirname + '/package.json', function(err, content) {
  var pkgJson;

  if (err) { throw err; }

  pkgJson = JSONparse(content);
  assert.equal(pkgJson.name, 'try-json-parse');
  assert(JSONparse(fs.readFileSync(__filename)) === undefined);
});
```

### Motivation

Got tired of writing try {} catch {}.

### License

MIT

---
_Source: https://npm.io/package/try-json-parse · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
