{"id":4066,"date":"2014-03-30T07:26:59","date_gmt":"2014-03-30T07:26:59","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/kineticjs-load-json-canvas-collection-of-common-programming-errors\/"},"modified":"2014-03-30T07:26:59","modified_gmt":"2014-03-30T07:26:59","slug":"kineticjs-load-json-canvas-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/kineticjs-load-json-canvas-collection-of-common-programming-errors\/","title":{"rendered":"Kineticjs load json canvas-Collection of common programming errors"},"content":{"rendered":"<p>&#8216;<strong>polygon1<\/strong>&#8216; It&#8217;s just one name &#8230; a change!!!! I take your code and place to run and continue with the same error! when i print the json I noticed that it has an error!<\/p>\n<p>he puts this <code>\"children\": \"[]\"<\/code> and should not have quotes in brackets if I copy and put my string this fixed string corrected wheel normal!! I made a method to remove the error &#8230;. Now I&#8217;m with an error<\/p>\n<pre><code>SyntaxError: JSON.parse: expected property name or '}'\n\n\nvar json = polygonLayer.toJSON();\njson = json.replace('\"children\":\"', '\"children\":');\njson = json.substring(0, json.length-2) + json.substring(json.length-1, json.length);\n<\/code><\/pre>\n<p>whereas using the same fixed string works!<\/p>\n<p>I&#8217;m using version 4.3.3<\/p>\n<p>this work<\/p>\n<pre><code>var json = '{\"attrs\":{\"clearBeforeDraw\":true,\"visible\":true,\"listening\":true,\"opacity\":1,\"x\":0,\"y\":0,\"scale\":{\"x\":1,\"y\":1},\"rotation\":0,\"offset\":{\"x\":0,\"y\":0},\"draggable\":false,\"dragOnTop\":true},\"nodeType\":\"Layer\",\"children\":[{\\\"attrs\\\": {\\\"width\\\": 600, \\\"height\\\": 400, \\\"cornerRadius\\\": 0, \\\"fillEnabled\\\": true, \\\"strokeEnabled\\\": true, \\\"shadowEnabled\\\": true, \\\"dashArrayEnabled\\\": true, \\\"fillPriority\\\": \\\"color\\\", \\\"visible\\\": true, \\\"listening\\\": true, \\\"opacity\\\": 1, \\\"x\\\": 0, \\\"y\\\": 0, \\\"scale\\\": {\\\"x\\\": 1, \\\"y\\\": 1}, \\\"rotation\\\": 0, \\\"offset\\\": {\\\"x\\\": 0, \\\"y\\\": 0}, \\\"draggable\\\": false, \\\"dragOnTop\\\": true, \\\"fill\\\": \\\"white\\\"}, \\\"nodeType\\\": \\\"Shape\\\", \\\"shapeType\\\": \\\"Rect\\\"}]}';\nlayer = Kinetic.Node.create(json, 'canvas');\n<\/code><\/pre>\n<p>but this dont work<\/p>\n<pre><code>var json = layer.toJSON();\nlayer = Kinetic.Node.create(json, 'canvas');\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8216;polygon1&#8216; It&#8217;s just one name &#8230; a change!!!! I take your code and place to run and continue with the same error! when i print the json I noticed that it has an error! he puts this &#8220;children&#8221;: &#8220;[]&#8221; and should not have quotes in brackets if I copy and put my string this fixed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4066","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4066","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4066"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4066\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4066"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4066"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}