Open sbstp opened 9 years ago
I removed the null
& 2
arguments from stringify
and the result is the same. It's not a pretty-printing error.
EDIT: Haven't been able to replicate with something else than the FFI code atm.
After investigation, it seems that it's a cycle detection issue.
var a = {qux: 'baz'};
var b = [a, a];
print(JSON.stringify(b, null, 2));
Outputs
[
{
"qux": "baz"
},
]
EDIT: Objects are also affected.
var a = {qux: 'baz'};
var b = {a: a, a: a};
print(JSON.stringify(b, null, 2));
Output
{
"a": {
"qux": "baz"
}
}
The output is valid JSON however.
I was debugging some code using
JSON.stringify
and it seems that some objects get truncated. That's the code in question.members
actually has 3 items. I've checked thelength
property. However, the output only has one element.If I print the 3 items manually, like below, it displays all of them.
Thinking it maybe was a
print
bug, I checked the length of the generated strings. They should be about the same, ± a few characters. There's a huge gap! Doesn't look like a bug with print.