Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

false positive for sibling (not-circular) references #9

Closed
proppy opened this issue Sep 4, 2013 · 5 comments
Closed

false positive for sibling (not-circular) references #9

proppy opened this issue Sep 4, 2013 · 5 comments
Assignees

Comments

@proppy
Copy link

proppy commented Sep 4, 2013

var safeStringify = require('json-stringify-safe')

var obj = { foo: 'bar' };

console.log(safeStringify({
    a: obj,
    b: obj
}));


console.log(JSON.stringify({
    a: obj,
    b: obj
}));

Will produce the following ouput:

{"a":{"foo":"bar"},"b":"[Circular ~.a]"}
{"a":{"foo":"bar"},"b":{"foo":"bar"}}

It seems to identify multiple sibling references to the same object as circulars.

@alexturpin
Copy link

Getting a similar problem that makes this unusable for me:

var safeStringify = require('json-stringify-safe');
var list = ["a", "b", "c"];
var obj = {list: list, foo: {bar: list}};
console.log("native", JSON.stringify(obj));
console.log("json-stringify-safe", safeStringify(obj));

Native JSON.stringify has no issue with it, but the safe stringify does. Output:

native {"list":["a","b","c"],"foo":{"bar":["a","b","c"]}}
json-stringify-safe {"list":["a","b","c"],"foo":{"bar":"[Circular ~.list]"}}

@jupiter
Copy link

jupiter commented Feb 3, 2015

+1

@moll
Copy link
Owner

moll commented Feb 3, 2015

Oops, time flies. I'll get to it, @jupiter. ;)

Marsup added a commit to Marsup/json-stringify-safe that referenced this issue Mar 3, 2015
@moll
Copy link
Owner

moll commented Mar 3, 2015

Comrades,

I copied the implementation from Must.js, perked it up a little and added a full test suite.
Would y'all mind giving it a spin and see if it does everything you imagined it should?
There's a CHANGELOG, but in summary it just doesn't report false positives any more.

Thanks a bunch!

@moll
Copy link
Owner

moll commented May 20, 2015

v5.0.1 is now released which I should fix this issue. ;-)

@moll moll closed this as completed May 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants