I have an REST API endpoint which the JSON response looks like:
{
"products": [
{"id": 1040, "price": 2.95, ...}
{"id": 4545, "price": 3.95, ...}
]
}
One of my colleagues suggested that I should add a key for each item in the list. He said it would make easier to browse the browse the API. The example above would become:
{
"products": {
"1040": {"id": 1040, "price": 2.95, ...}
"4545": {"id": 4545, "price": 3.95, ...}
}
}
Making it will not be harmful for my API's performance and I can understand how it should improve the browsability. Should I do that? Is there any example of public API that does something similar?