开发者

json save to db and use it after

how to convert this json to database:

var obj = {
   'one' : ['qq','rr'],
   'pizda' : { }开发者_StackOverflow社区
}

and then retrive it and use it?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜