json-smart

1.0.1 • Public • Published

JSON_smart

JSON tool kit, support circular structure / solve Uncaught TypeError.

Installation

$ npm install json-smart

Example

const JSON_smart = require('JSON_smart');
var obj = {
    version: "1.0.1",
    g: typeof(window) !== "undefined"?window:global,
    circularOBJ: {},
    deepCircular: {}
}
obj.circularOBJ.self = obj.circularOBJ;
obj.deepCircular = {
    one: {
        tow: {
            more: {
                root: obj
            }
        }
    }
}
obj.deepCircular.self = obj.deepCircular
var json = JSON_smart.stringify(obj);
var parsed = JSON_smart.parse(json);
console.log(json);
console.log(parsed);

output:

{
	"version": "1.0.1",
	"g": "[Global Object]",
	"circularOBJ": {
		"self": "[CIRCULAR ~.circularOBJ]"
	},
	"deepCircular": {
		"one": {
			"tow": {
				"more": {
					"root": "[CIRCULAR ~]"
				}
			}
		},
		"self": "[CIRCULAR ~.deepCircular]"
	}
}

{version: "1.0.1", g: Window, circularOBJ: {…}, deepCircular: {…}}

Usage

like JSON.

About

have fun.

Package Sidebar

Install

npm i json-smart

Weekly Downloads

0

Version

1.0.1

License

GPL-3.0

Unpacked Size

41.5 kB

Total Files

6

Last publish

Collaborators

  • tacopie