javascript - Not creating json object -
i'm playing around fabric js, can't seem find way create/view json object
var canvas = new fabric.canvas('c'); canvas.add(new fabric.rect({ left: 100, top: 100, width: 50, height: 50, fill: '#faa', originx: 'left', originy: 'top', centeredrotation: true })); canvas.add(new fabric.circle({ left: 300, top: 300, radius: 50, fill: '#9f9', originx: 'left', originy: 'top', centeredrotation: true })); var w = canvas.tojson();
http://jsfiddle.net/8t4k1xkc/1/
i tried json.stringify got converting circular structure json error
the code wrote in question works, can turn string json.stringify(w)
call json.stringify(canvas)
(tojson called stringify).
the 1 on jsfiddle, not, calling canvas.tojson(c)
, wrong, way appending additional properties resulting json, in case same canvas (c
, global variable automatically created browser html element id="c"), circular structure error.
tojson(propertiestoinclude)
returns json representation of canvas
parameters:
- propertiestoinclude (array): properties might want additionally include in output
Comments
Post a Comment