
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
json-circular
Advanced tools
Simple library to allow for serialization and deserialization (JSON or otherwise) of JS objects containing circular references
Simple Node.js library to allow for serialization and deserialization (JSON or otherwise) of JS objects containing circular or internal references
A simple example:
var JsonCircular = require('json-circular');
var demoObj = {"data": []};
demoObj.parent = demoObj;
demoObj.data.push(demoObj);
var json = JsonCircular.stringify(demoObj);
var demoObj2 = JsonCircular.parse(json);
If JSON is not the desired object serialisation method, the library can be used to prepare objects for serialisation, and restore the object after deserialisation. Warning: the library will modify the original object in preparation for serialisation, though it can be restored by running the post-processor on the object when serializaztion is complete:
var JsonCircular = require('json-circular');
var demoObj = {"data": []};
demoObj.parent = demoObj;
demoObj.data.push(demoObj);
//This will modify demoObj
JsonCircular.preprocess(demoObj);
var serializedStr = MyCustomSerializationFunction(demoObj);
//This will restore demoObj to it's original state
JsonCircular.postprocess(demoObj);
//For de-serialization
var demoObj2 = MyCustomDeserializationFunction(serializedStr);
JsonCircular.postprocess(demoObj2);
The preprocess and postprocess methods return the object that is passed in, so can be stacked thusly:
var demoObj2 = JsonCircular.postprocess(MyCustomDeserializationFunction(demoObj2));
###Configuration The library has two configuration options, exposed as fields in the JsonCircular object.
FAQs
Simple library to allow for serialization and deserialization (JSON or otherwise) of JS objects containing circular references
The npm package json-circular receives a total of 1,032 weekly downloads. As such, json-circular popularity was classified as popular.
We found that json-circular demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.