The object or array to decycle.
Optionalreplacer: ReplacerFunctionOptional replacer function called for each value.
$ref objects.var a = [];
a[0] = a;
JSON.stringify(decycle(a)); // '[{"$ref":"$"}]'
If a replacer function is provided, then it will be called for each value. A replacer function receives a value and returns a replacement value.
JSONPath is used to locate the unique object. $ indicates the top level of
the object or array. [NUMBER] or [STRING] indicates a child element or
property.
Makes a deep copy of an object or array, assuring that there is at most one instance of each object or array in the resulting structure. The duplicate references (which might be forming cycles) are replaced with an object of the form
{"$ref": PATH}where the PATH is a JSONPath string that locates the first occurance.