The issue is to decide the trade offs between the following notations:
JSON based:
"users": {
"id1": {
"id": "id1",
"firstname": "firstname1",
"lastname": "lastname1"
},
"id2": {
"id": "id2",
"firstaame": "firstname2",
"lastname": "lastname2"
}
}
Array Based:
users: [
{
"id": "id",
"key2": "value2",
"key3": "value3"
},
{
"id": "id",
"key2": "value2",
"key3": "value3"
}
]
Relating to this post on the same issue, I have decided (on front end) to use the JSON object notation instead of an array of objects as it suits my requirements, provides better performance, and results in less code in the browser.
But the problem is that the list itself is not static. By this I mean the list is being generated i.e. fetched/stored from DB (NoSQL) and created for new entries through a Java API on the server. I am not able to decide on which notation I should use at the back end (which eventually will also affect the UI too).
Any thoughts/suggestions about performance, maintainability or scalability is appreciated.
id
(for JSON), but in case of array I have to loop through the whole list and match theid
property of each object, which can be a bottleneck in case of large data sets. So JSON works fine for me in browser but I am not sure is creating the same structure by Java will have any performance issues.{}
or an array[]
. So the terminologyJson based
vsArray based
should actually be(Json)-Object based
vs.(Json)-Array based