@thaddeusjiang/safejsonparse
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Safe JSON.parse()

no exception.

You don't need to write try-catch in everywhere.

Install

npm install @thaddeusjiang/safejsonparse

Usage

import safeJSONparse from '@thaddeusjiang/safejsonparse'

safeJSONparse('') // undefined

safeJSONparse('{ "value": wrong JSON }') // undefined

safeJSONparse('{ "name": "TJ" }') // { "name": "TJ" }

safeJSONparse('[1,2,3]') // [1,2,3]

Package Sidebar

Install

npm i @thaddeusjiang/safejsonparse

Weekly Downloads

13

Version

0.1.2

License

MIT

Unpacked Size

5.99 kB

Total Files

15

Last publish

Collaborators

  • thaddeusjiang