1.0.0 • Published 6 years ago
stringify-once v1.0.0
stringify-once
JSON stringify without Converting circular structure to JSON
error.
Note: this snippet was extracted from an awesome answer at StakOverflow, from here to be honest. Thanks to the users that posted, edited and helped to give this answer (1, 2 and 3).*
1. Installation
~$ npm install --save stringify-once
2. Usage
First, you need to import the module from your code:
const stringify = require("stringify-once");
Once you have added the code into your project, you will be able to:
JSON.stringifyOnce(window); // not formatted
JSON.stringifyOnce(window, null, 4); // formatted
stringify(window); // not formatted
stringify(window, null, 4); // formatted
Notice that the method used is not JSON.stringify
, but JSON.stringifyOnce
.
3. Conclusion
There are lots of awesome codes in StackOverflow. Lots of them.
1.0.0
6 years ago