Why commas over repeated key?

The docs use:

fields[articles]=title,body

Instead of:

fields[articles]=title&fields[articles]=body

1 Like

At least one reason could be that on a lot of platforms only one value would be available: given that HTTP (URI)-specific RFCs don’t put any specifics on query parameters any parsing behaviour is “valid”. So if you use the former - you would need to implement your own URI parser.

You could also address the question the answer way around: Why should a key be repeated?

The specification forbids to use a comma in attributes (and relationship) names. It is a reserved character. Using it as a delimiter in a list of attributes as done for Sparse Fieldsets is safe therefore.

A list with using a comma as delimiter is shorter than repeating the key. It should be also easier to parse in nearly all implementations as @zerkms pointed out. It should also reduce the network traffic a little bit as the URLs are shorter.

Long story short: I don’t see a value in using repeated keys. But I see values in using a list with comma as a delimiter.