1.0.4 • Published 5 years ago
referential-json-stringify v1.0.4
referential-json-stringify
Provides stringify
/parse
functions for converting objects with shared/circular references to/from JSON
How to Use
Browser
- Download ./dist/referential-json-stringify.min.js and add it to your project's files
- Add
<script src='referential-json-stringify.min.js'></script>
to your page's<head>
- call
referentialJsonStringify.stringify
andreferentialJsonStringify.parse
as needed
Node
npm install referential-json-stringify
import { stringify, parse } from 'referential-json-stringify';
- call as needed
Example
import { stringify } from 'referential-json-stringify';
const a = {
name: 'a',
};
a.a = a;
const b = {
name: 'b',
a,
};
const root = {
name: 'root',
a,
b,
};
stringify(root);
// [
// "root",
// {
// "name":2,
// "a":1
// },
// "a",
// {
// "name":4,
// "a":1
// },
// "b",
// {
// "name":0,
// "a":1,
// "b":3
// }
// ]