Gathering detailed insights and metrics for json-cycle
Gathering detailed insights and metrics for json-cycle
Gathering detailed insights and metrics for json-cycle
Gathering detailed insights and metrics for json-cycle
Utilities provide ability to encode/decode cyclical structures.
npm install json-cycle
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.7
Supply Chain
100
Quality
75.7
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
238,413,224
Last Day
42,055
Last Week
1,261,830
Last Month
5,484,889
Last Year
59,725,566
MIT License
43 Stars
32 Commits
13 Forks
5 Watchers
1 Branches
4 Contributors
Updated on Jan 14, 2025
Minified
Minified + Gzipped
Latest Version
1.5.0
Package Id
json-cycle@1.5.0
Unpacked Size
11.12 kB
Size
4.20 kB
File Count
4
NPM Version
8.1.0
Node Version
16.13.0
Published on
Apr 21, 2023
Cumulative downloads
Total Downloads
Last Day
4.6%
42,055
Compared to previous day
Last Week
-8.6%
1,261,830
Compared to previous week
Last Month
2.2%
5,484,889
Compared to previous month
Last Year
2%
59,725,566
Compared to previous year
Utilities provide ability to encode/decode circular structures for converting to and from JSON.
Based on JSON-js
In your project:
npm install json-cycle --save
This package contains four functions, decycle, retrocycle, stringify and parse, which make it possible to encode cyclical structures and convert them to JSON, and then recover them. This is a capability that is not provided by ES5. JSONPath is used to represent the links. [http://GOESSNER.net/articles/JsonPath/]
Note: If you stringify javascript structure and then parse it back in some cases you can get not the same javascript structure. For instance, if it contains Date object you get String form of it.
Note:
decycle
function makes a deep copy of any provided structure while originaldecycle
function from JSON-js does not make copy forBoolean
,Date
,Number
,RegExp
andString
objects.
Makes a deep copy of an provided structure with resolving all circular references. The duplicate references which part of an cycle are replaced with an object of the form
{$ref: PATH}
where the PATH is a JSONPath string that locates the first occurrence.
Example:
1 jc = require('json-cycle'); 2 var a = {}; 3 a.self = a; 4 console.log(JSON.stringify(jc.decycle(a)));
Output:
1 {{"$ref":"$"}}
returns provided object
Restores an object that was reduced by decycle
function. Members whose values are
objects of the form
{$ref: PATH}
are replaced with references to the value found by the PATH. This will restore cycles. The object will be mutated.
Note: The eval function is used to locate the values described by a PATH. The root object is kept in a $ variable. A regular expression is used to assure that the PATH is extremely well formed. The regexp contains nested
Example:
1 jc = require('json-cycle'); 2 var s = '{{"$ref":"$"}}'; 3 jc.retrocycle(JSON.parse(s));
Output:
1 produced object equals to 2 var a = {}; 3 a.self = a;
It equals to JSON.stringify(decycle(object))
It equals to retrocycle(JSON.parse(object))
MIT © 2015-... Valery Barysok, Douglas Crockford
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 4/23 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More