Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

safe-jsonparser

Install

readme

SAFE-JSON-PARSER

Install

yarn add safe-jsonparser

Usage

import safeJsonParse from 'safe-jsonparser'
//or
const safeJsonParse = require('safeJsonParse')

// valid json string
safeJsonParse('{"a":1}') // return {a: 1}

// invalid json string
safeJsonParse('{"a:1}') // return undefined

// invalid json string with error callback
safeJsonParse('{"a":1}', console.error) // return undefined and log error