tags:

views:

27

answers:

2

how to convert this json to database:

var obj = {
   'one' : ['qq','rr'],
   'pizda' : { }
}

and then retrive it and use it?

+1  A: 

Assuming that the database runs on the webserver and you thus need to pass the JSON as a string around between webserver and webbrowser, then the answer depends on the server side language you're using.

If you're using PHP, then you can convert between a JSON string and a PHP array using json_decode() and json_encode()

If you're using JSP/Java, then there are several libraries available to convert between a JSON string and a Java object, the popular ones being Google Gson, JSON.org and Jackson.

If you're using ASP/.NET, then there are several libraries available as well, under each Google JSONSharp.

Also see the bottom of this page for an overview of several JSON parsers/formatters in various languages.

BalusC
+2  A: 

You could store it in mongodb without too much effort.

db.foo.save(obj); // Save obj to a database
db.foo.find(); // find it again.

You might want to give a bit more details.

DiggyF