At the moment we have an AJAX driven site that returns a JSON response in the following format: [{"n":"bob"}, {"n":"jim"}, ..., {"n":"alex"}]. Basically an array of json objects.
However we are thinking about structuring it like so: [["bob"], ["jim"], ..., ["alex"]]. Basically an array of arrays.
The obvious difference is that instead of accessing the data via its properties, we’d be accessing it via assumed index positions (i.e., array[0] == name), but besides that I am curious what the pros/cons are of each. Interesting factors: performance on the client (both constructing the data structure and retrieving its values), bandwidth (obviously on larger data sets or for slower internet connections, say mobile devices), design pattern/best practice, how others have designed their responses, etc…
When using an object-in-array format, you can load more data per item, and not just
n.When using the array, the data return is assumed to be of the same kind.
but it all boils down to how you parse data.
structuring data like this:
is totally wrong. why put the name in an array, in an array of names? what’s the second level for?