According to the information provided by (Mozilla) in the JSON.stringify documentation (https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON_behavior)
Explanation of toJSON() method
When an object being converted to a string has a toJSON property that is a function, the toJSON() method dictates how the object is stringified. Instead of serializing the entire object, the
value that the toJSON() method returns upon execution will be serialized.
For instance:
If you execute the following code, you should receive similar outcomes
function testing() {
foo = canvas.getObjects()[0];
bar = JSON.stringify(canvas.getObjects()[0]);
console.log(foo.toJSON());
console.log(bar);
}
Alternatively, by setting the toJSON property to undefined (although this might cause issues with fabric.js unless performed on a clone of the object - I have directly applied it to the object below)
function testing() {
foo = canvas.getObjects();
bar = JSON.stringify(canvas.getObjects().map(function (o) {
o.toJSON = undefined;
return o
}));
console.log(foo);
console.log(bar);
}