I have to store some entities (amazon nodes), which have id and name properties
A node may or may not have sub nodes.
Sub nodes too consists the id and name.
There’s no limit to nesting. A sub node can have sub nodes and that sub node can have sub nodes of its own.
I chose to save this in json ( I am comfortable working with json )
e.g.
A History node has subnodes architecture and landmarks.
Here’s how I am storing this in json.
[
{
"id" : "14278871",
"name" : "History"
"sub" : [
{
"id" : "173508",
"name" : "Architecture"
},
{
"id" : "1000",
"name" : "Landmarks"
}
]
}
]
But it seems to be too much of data. Can someone provide me a better way ?
In xml, I came up with this,
<history id="14278871">
<architecture id="173508"></architecture>
<landmarks id="1000"></landmarks>
</history>
I am looking for better ways to store this data.
Ultimately, I need to use this data in php.
The difference between your two formats isn’t really the data structure, it’s that you’ve switched the
namefields from being data to being keys. The analogous JSON to your XML would be: