I just got bitten because some data instances don't follow the same pattern as others, and cannot be predicted. Many user affiliations look like this but there are some that look like that.
This cannot be guessed because there is no schema documenting the expectation, and it can easily cause an application to malfunction (it just did).
More generally, the pattern of exposing a field as a array if there are several items but as a scalar when there is only one is a poor one. You're much better off with always having an array, possibly of one item.
I just got bitten because some data instances don't follow the same pattern as others, and cannot be predicted. Many user affiliations look like this but there are some that look like that.
This cannot be guessed because there is no schema documenting the expectation, and it can easily cause an application to malfunction (it just did).
More generally, the pattern of exposing a field as a array if there are several items but as a scalar when there is only one is a poor one. You're much better off with always having an array, possibly of one item.