try-parse-json

1.0.2 • Public • Published

try-parse-json

JSON.parse() wrapped in a try catch. Returns any error instead of throwing.

Usage

var tryParseJSON = require('try-parse-json');
 
tryParseJSON('{"a": 1, "b": 2}') // {a:1, b:2}

Errors

tryParseJSON('[1, 2, 3,]').message // 'Unexpected token ]'

Readme

Keywords

none

Package Sidebar

Install

npm i try-parse-json

Weekly Downloads

1,114

Version

1.0.2

License

MIT

Last publish

Collaborators

  • mattlarner