
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
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,345 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
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.