Splendid UI
Components and utilities for the modern web
-->
parseJSON
is a utility that lets you do two things in a single line:
First, make sure you install Splendid UI.
npm install splendid-ui
Then import parseJSON
into your project.
import { parseJSON } from 'splendid-ui/utils'
When you use parseJSON
, just specify the JSON you wanto parse and a defaultValue
you wish to provide.
const value = parseJSON(json, defaultValue)
// If JSON is valid value will be === JSON data
// If JSON is invalid, value will be === defaultValue
That’s all you need to know to use parseJSON
!