0

I have an empty layer (not really empty, I have drawn a grid there, so there's lines and rectangles), and another layer similar to the first layer, where I dragged and dropped multiple shapes and images. What I want to do is:

  • Save the second layer (called rightLayer) using toJSON(): done!
  • Draw the saved JSON in the first layer, and save it again : not yet, because..

In the docs, I should do this :

var json = rightLayer.toJSON();
var layer1 = Kinetic.Node.create(json, 'container');

Whereas I don't want to actually create the layer, it's already there, I just need to draw on it. How do I do it without creating a variable?

A second question: Can JSON format be saved in database? I'll need to store the JSON in order to display it later.

Sahar Ch.
  • 489
  • 1
  • 8
  • 28

1 Answers1

1

Answering your 2nd question, there are a few databases that use JSON storage, or in other words, document-oriented storage. Examples of those databases are: MongoDB and CouchDB. Im currently using MongoDB in my project and it seems to be a very powerful and complete database.

pgrodrigues
  • 2,083
  • 1
  • 24
  • 28
  • I'm using microsoft SQL server DB (the DB tables exist) and I'm thinking about adding a row to a table. Is it feasible or it's necessary to use another database? – Sahar Ch. May 20 '14 at 08:27
  • I would like to suggest reading this [post](http://stackoverflow.com/questions/15367696/storing-json-in-database-vs-having-a-new-row-for-each-key). The answers there provide a good overview regarding the non-relational and relational models. – pgrodrigues May 20 '14 at 08:54
  • Maybe the way to do it, since I'm limited by the database, is storing json in a xml data type in Microsoft DB and then use Json.NET framework (still don't know it) to convert from json to xml and vice versa. Not sure yet, I just searched. Thanks for the reply :) – Sahar Ch. May 20 '14 at 08:57