1.0.4 • Published 5 years ago

referential-json-stringify v1.0.4

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

referential-json-stringify

Provides stringify/parse functions for converting objects with shared/circular references to/from JSON

How to Use

Browser

  1. Download ./dist/referential-json-stringify.min.js and add it to your project's files
  2. Add <script src='referential-json-stringify.min.js'></script> to your page's <head>
  3. call referentialJsonStringify.stringify and referentialJsonStringify.parse as needed

Node

  1. npm install referential-json-stringify
  2. import { stringify, parse } from 'referential-json-stringify';
  3. 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
// 	}
// ]
1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago