doujia5863 2011-10-18 20:20
浏览 48
已采纳

存储JSON响应的最佳方法是什么?

I was wondering what would be the best way to store JSON/XML responses. I'm currently building an application that supports heavily on the SoundCloud API to fetch songs/playlists etc.

Here are some ideas I've come up with.

  1. Storing the results in a Relational Database and then using PHP to convert them to classes to make easy use of them throughout my application.
  2. Doing the above, only this time using my framework's built-in ORM.
  3. Using a Document-Oriented Database. (ie. MongoDB, couchDB, ...)
  4. Storing the JSON responses in a cache. (using my framework's cache classes)

Can anyone care to shed some light on some of the advantages/disadvantages of using any of these methods?

Which one do you prefer?

  • 写回答

3条回答 默认 最新

  • dongxuandong2045 2011-10-18 20:22
    关注

    If you have a solid schema, that you wont think it will change, you might want to use relational database. You will need to parse the json and make objects out of the JSON response and using your framework you can persist it to database.

    If you think your schema will change use NoSQL.

    It also depends what will you do with this data. Are you going to search the nodes within JSON? You can also do a object to mongo mapping, you can either parse the JSON and store it as an object or you can store the JSON the way it is.

    Nice thing about NOSQL is that they support JSON pretty well in which they use BSON (Binary JSON).

    In terms of cache, IME, it should be used only for lookups, and actually, you cant search the cache. It s just for getting objects faster than going to database and getting it.

    Take a look at this:

    http://www.mongodb.org/display/DOCS/Inserting#Inserting-JSON

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 echarts动画效果失效的问题。官网下载的例子。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加