如何将JSON数据存储在磁盘上? [英] How do I store JSON data on a disk?

查看:211
本文介绍了如何将JSON数据存储在磁盘上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JSON的新手,我可能需要在将来使用它,所以我做了一些阅读。关于SO的JSON有很多问题。我找到了大量使用谷歌的文章,我读了json.org,但我不明白如何存储JSON数据。

I am totally new to JSON and I might need to use it in the future so I did some reading bout it. There's lots of questions regarding JSON on SO. I found heaps of articles using google, I read json.org but I did not understand how to store JSON data.

JSON是一种轻量级的数据交换格式。那么我如何存储其数据?在文件中?在数据库?这有关系吗?

JSON is is a lightweight data-interchange format. So how I store its data? In a file? In a database? Does it matter?

我可以用它将数据传递给 jsTree (jsTree是一个基于javascript的跨浏览器树组件。它打包为jQuery插件。)它将与Wordpress一起使用。我想了解如何存储数据?在文件中?文本文件?在Wordpress数据库中?哪一个更快?更好用吗?

I can use it to pass the data to jsTree (jsTree is a javascript based, cross browser tree component. It is packaged as a jQuery plugin.) It would be with Wordpress. I am trying to understand how I will store the data? In a file? Text file? In Wordpress database? Which one is faster? Better to use?

CURRENT STATUS 在任何编码之前,没有应用程序正在运行

CURRENT STATUS before any coding,there is no application running


  • 我正在准备源数据,到目前为止,我的源csv文件大小为235KB ,大​​约有700行(line = future nodes / leaves)。我使用csv文件只是为了收集数据,然后我将上传/更新网络服务器上的数据源。

  • 这个数字会增长,让我们每周说5-10。

  • 该文件位于我的本地计算机上,并将以某种方式存储在虚拟主机服务器上。请注意,我将在Wordpress中使用整个应用程序jsTree + JSON

  • 我想我可以使用它:现在使用Wordpress解析客户端json

  • I am preparing the source data and so far my source csv file is 235KB in size with about 700lines (line = future nodes/leaves). I use csv file just to collect data then I will upload/update the data source on the web server.
  • The number is going to grow let's say every week by 5-10.
  • The file is on my local computer and will be stored (somehow) on a webhosting server. Please note that I will use the whole application jsTree+JSON within Wordpress
  • I guess I can use this: Now parse Client side json with Wordpress

推荐答案

我想首先要理解的是,JSON只是表示信息的一种方式。您可以随意存储数据。如果你有一个关系数据库,你可能会想出一种合理的方法来回转换数据。

I guess the first thing to understand is that JSON is just one way of representing information. You can store the data however you like. If you have a relational database, you can probably come up with a reasonable way of converting the data back and forth.

{ 
  "id": 321
  "name" : "Jim",
  "age" : 27,
  "email" : "jim@jimsoft.com"
}

可以用xml表示为

<person>
   <id>321</id>
   <name>Jim</name>
   <age>27</age>
   <email>jim@jimsoft.com</email>
</person>

或者可能存储在看起来像

Or might be stored in the a table that looks like

_______________________________________
| id | name | age | email              |
========================================
|321 | Jim  | 27  |jim@jimsoft.com     |
----------------------------------------

因此,如果您可以存储您想要的信息。您只需要某种方法将数据序列化/反序列化为您想要的任何形式。

So if you can store the information however you want. You just need some way to serialize/unserialize the data into whatever form you want.

如上所述,如果您需要存储 JSON并将其存储为文件将无法正常工作,您可能需要查看在 CouchDB MongoDB的。它们是面向文档的数据库,实际存储JSON文档。它们将允许您存储所需的任何JSON文档。您可以直接构建视图和查询数据,而无需将数据转换为不同的形式。

All that being said, If you need to store the JSON and storing it as a file won't work, You probably want to look at CouchDB or MongoDB. They are document-oriented databases that actually store JSON documents. They will let you store whatever JSON documents you want. You can build views and and query the data directly without having to convert the data to different forms.

这篇关于如何将JSON数据存储在磁盘上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆