0.0.1 • Published 2 years ago
parse-json-safe v0.0.1
parseJsonSafe
Features
- parse json without try catch。
- support default value;
- 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.1
2 years ago