A JSON serializer/deserializer that handles circular references, enabling safe serialization of complex object graphs.
CircularJSON is a JavaScript library that serializes and deserializes JSON objects containing circular references. It solves the limitation of native JSON methods, which throw errors when encountering recursive structures, by converting them into a specialized format that preserves references.
JavaScript developers working with complex object graphs, such as those in state management, caching systems, or data layers where objects reference each other.
Developers choose CircularJSON because it provides a reliable, API-compatible solution for circular reference handling without data loss, unlike simpler alternatives that only mask references for logging purposes.
JSON does not handle circular references. Now it does
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Serializes objects with self-references or mutual dependencies using a specialized format, as shown in the example where object.arr contains circular references that are preserved upon deserialization.
Produces minimized output with `~` prefixes to denote reference paths, reducing payload size, which is highlighted in the key features and usage example.
Uses the same stringify/parse API as native JSON for easy integration, as stated in the description and API section, making it drop-in replaceable.
Works in Node.js and browsers, compatible with all JavaScript engines, as per the README's installation instructions and compatibility notes.
Maps identical objects once during serialization, conserving memory and bandwidth, which is emphasized in the philosophy and key features for efficient data handling.
The README explicitly states that CircularJSON is in maintenance only and flatted is its successor, indicating limited future updates and potential deprecation.
Serialized output uses a custom format with `~` prefixes, which requires CircularJSON to parse, limiting interoperability with systems expecting standard JSON, as noted in the API warnings.
For projects without circular references, using CircularJSON adds unnecessary complexity and performance overhead compared to native JSON, as it processes references even when not needed.