moderator

General  - 
 
What's your preferred method of passing arrays into a query string? Feel free to share what you use in practice in addition to what you've been told is the /right/ way.

 [ 0 ]  http://foo.com/woot?user=larry&user=daryl

 [ 1 ]  http://foo.com/woot?user[0]=larry&user[1]=daryl

 [ 2 ]  http://foo.com/woot?user=larry,daryl

 [ 3 ]  http://foo.com/woot?user=["larry","daryl"]

 [ n ]  ...
1
1
Jonathan Ballard's profile photoJohn Sheehan's profile photoAbraham Williams's profile photoPraveen Alavilli's profile photo
14 comments
 
Really depends on if order of the values has to be guaranteed. In the past I've implemented support for both 0 & 2 while i was at AOL for the open_auth api and it worked really well for unordered arrays. 
 
There's a pull request on iodocs for V1. One thing that irks me -- even if there's just one element it should be user[0] if the input is an array. Looking forward to more comments on this.
 
Jonathan, my G+ client is showing your example of params in the fragment. Can you clarify?
 
Go with [0].  Perl, Ruby, node.js, etc. can deal with that form already without any real effort on your part.
 
+Paul Jones That depends on authorization level. [0] seems easy until secured connections are required. The array may need more public version(s) of the information provided before sent over the network. There are more cases to digress upon.
 
+Jonathan Ballard, why does secure connections matter? The question was what is the preferred way to pass arrays via a query string. Using either HTTP or HTTPS presents the same question. What are you referring to exactly?
 
+Paul Jones I have seen many requests for private URIs. The effort to correct URIs to any particular scheme is easier with fragments. [0] is like the URI with fragment sent without any extra process. Exactly how that becomes private is another security issue, so.... hope this helps with domain science.
 
One thing to keep in mind about 0/1 is the poor key:value ratio. As you add more values the characters wasted on they key continues to increase. This could be an issue with some servers if you are making large requests and the query string becomes to long.
 
+Jonathan Ballard, I guess I'm still missing your point. He's asking about the query string and how to best present an array. I don't understand how security is an issue.  I also don't understand the point about fragments, either.  Those are not even sent to the server.
 
+Paul Jones The current image of this community represents the more declarative sample of an array of data (or objects as stated by json.org). The point was Neil's questions.
 
I prefer 0 because most web frameworks and HTTP clients are conditioned to handle those without any extra work. If order is required, I'm with everyone else that 2 is best.
Add a comment...