0.0.3 • Published 6 months ago

parse-json-safe v0.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

parseJsonSafe

Features

  1. parse json without try catch。
  2. support default value;
  3. object value will be returned as it self;

Usage

import { parseJsonSafe } from "parse-json-safe";
// normal
const json = parseJsonSafe(`{ "a": 1 }`);
// { a: 1 }

// when catch error, output default value
const json = parseJsonSafe("err", { a: 0 });
// { a: 0 }

// support object type
const json = parseJsonSafe({ a: 1 });
// { a: 1 }
0.0.3

6 months ago

0.0.2

6 months ago

0.0.1

3 years ago