Array of Objects or Array of arrays? I build phone apps and I use JSON a lot in my APIs. The problem is sometimes I don't know how to format the JSON data.

For example, an iOS UITableView takes NSArray as datasource.

{
    "contact_id": [
        "455",
        "464"
    ],
    "contact_name": [
        "Administrator",
        "Main contact"
    ]
}


For me it makes sense since I don't have to loop through anything, but I was told it is not safe to rely on the indices matching the position.

I remember, while asking questions, people bringing to my attention to be careful not to separate records into different arrays, and instead I should return array of objects:

[
    {
        "contact_id": "455",
        "contact_name": "Administrator"
    },
    {
        "contact_id": "464",
        "contact_name": "Main contact"
    }
]


I would like to know the best practice to formatting JSON.
Keep related data together.


Does your application need a list of contacts? Keep each contact intact with the second approach. Merging data to create and pass a single contact takes work and is error-prone. 
Does it need a list of contact IDs? Do the same or return just that list. With the latter approach you can easily produce a limited array. Going the other way is much harder (more code).
Does it need a list of contact names in a drop-down that loads the full contact for one ID? Use the latter since you get everything up-front. 


The short answer is Keep related data together because it's generally easier to pull it apart than merge it back together.