The issue is to decided the trade offs between following notations:
JSON based:
\"users\": {
\"id1\": {
\"id\": \"id1\",
It is a total opinion based question. There might be many other points, but I can point out as below.
JSON based approach :
If I am not wrong then this will be implemented using Map
on server side.
Advantage : In JavaScript you can directly use users.id1, users.id2 i.e. no need of iteration
Disadvantage : On client side, some how you will require the ids present in your JSON i.e. either hard coding it or using some dynamic approach which will tell you which id is present in your JSON.
Array Based approach : If I am not wrong then this will be implemented using Array
/List
on server side.
Advantage:
Disadvantage : If you want to fetch single id then you will need to iterate through the array.
Generally we don't send much information on client side, so array based approach will not create any problem. And transforming array into map is possible on both the side (server and client) if you want id based approach.