I've been encountering some issues while attempting to store data in JSON and then reload it onto the canvas using fabric.js. My code is quite simple:
canvas.add(new fabric.Rect({ width: 50, height: 50, fill: 'red', top: 100, left: 100 }));
var c = canvas.toJSON();
canvas.clear();
canvas.loadFromJSON(c);
However, I keep running into this error:
SyntaxError: JSON.parse: unexpected character
[Break On This Error] var Cufon=(function(){var k=function()....Image.fromElement.async=true})(this);
Even when I validate my own JSON, I still encounter errors when trying to use the output produced by fabric's canvas.toJSON() method. Does anyone have any successful examples of reloading data from a previous canvas state in fabric.js onto an empty canvas? Any help would be greatly appreciated!