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 is is a lightweight data-interchange format. So how I store its data? In a file? In a database? Does it matter?
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 before any coding,there is no application running
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" : "[email protected]"
}
Might be represented in xml as
<person>
<id>321</id>
<name>Jim</name>
<age>27</age>
<email>[email protected]</email>
</person>
Or might be stored in the a table that looks like
_______________________________________
| id | name | age | email |
========================================
|321 | Jim | 27 |[email protected] |
----------------------------------------
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.
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.
Somethings like CouchDB are a database that store it internally in a file. Most people don't /store/ JSON at all, they generate it and send it, or parse it and process it.
JSON is an ideal format for serializing data, but the same caveats apply to it as any other serialization format. Do you store XML in a DB? Usually not. The difference being XML makes sacrifices to include humans use, and JSON makes sacrifices to be easily parseable and fast.
JSON is not really a replacement for a CSV. Think of a CSV as loosely-formated table specific dumping mechanism. It wouldn't make too much sense to have a JSON export in excel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With