refify

Safely stringify & parse circular references to & from JSON using JSON pointers

npm install refify
2 downloads in the last week
8 downloads in the last month

refify

Synopsis

var refify = require('refify');

var o = {};
o.circular = o;

refify(o)                           //=> {circular: {$ref: "#/"}}
refify.stringify(o)                 //=> '{"circular":{"$ref":"#/"}}'
refify.parse('{"o":{"$ref":"#/"}}') //=> {circular: [Circular]}

Description

This module allows you to safely JSON.stringify objects with circular references. Circular references are replaced with document-relative JSON references. This provides a clear and unambiguous encoding that is already supported by other tools. A simple example:

Install

npm install refify

License

MIT

npm loves you