Load Stage with JSON String

To deserialize a JSON string with Konva, we can use the Konva.Node.create()
method which creates a node from a JSON string. If we want to deserialize
a stage node, we can also pass in an optional container parameter.

Konva Simple Load Demoview raw
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.rawgit.com/konvajs/konva/1.6.2/konva.min.js"></script>
<meta charset="utf-8">
<title>Konva Simple Load Demo</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #F0F0F0;
}
</style>
</head>
<body>
<div id="container"></div>
<script>
var json = '{"attrs":{"width":578,"height":200},"className":"Stage","children":[{"attrs":{},"className":"Layer","children":[{"attrs":{"x":100,"y":100,"sides":6,"radius":70,"fill":"red","stroke":"black","strokeWidth":4},"className":"RegularPolygon"}]}]}';
// create node using json string
var stage = Konva.Node.create(json, 'container');
</script>
</body>
</html>