So I'm currently trying to develop a JSON document which will be easiest to iterate through and access objects from. I will be using underscore, so accessing objects isn't necessarily difficult, but I'm wondering what the best way of going about formatting is - best practices, etc.
Here're the two formats I'm considering: The first is an array
{
"defaultViews" : [
{
"name" : "view1",
"title" : "View 1"
},
{
"name" : "view2",
"title" : "View 2"
}
]
}
Or, the other way, which is more.... "object oriented"...
{
"defaultViews" : {
"view1" : {
"title" : "View 1"
},
"view2" : {
"title" : "View 2"
}
}
}
So in the first example it's easier to iterate through the objects, whereas in the second example it's easier to access the object directly (obj.defaultViews.view1). I suppose this is quite subjective, but again I'm looking for what's hopefully considered a "best practice". Thanks!
view1,view2) are unique while in first notation there is not such limitation.