1.0.1 • Published 1 year ago

simple-safe-stringify v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

simple safe stringify

A JSON stringifier that does not fail on circular structures or bigints

Usage

  1. Install the package npm i simple-safe-stringify
  2. Import the module in your project
import { stringifySafe } from "simple-safe-stringify";
  1. Stringify any object
const circularObject = {
    some: {
        levels: {
            deep: null
        }
    }
};
circularObject.some.levels.deep = circularObject.some;

const json = stringifySafe(circularObject);

console.log(json); // '{"some":{"levels":{"deep":"[CIRCULAR #1]"}}}'