On Mon, Sep 20, 2010 at 11:56 PM, Adam Barth <[email protected]> wrote: > Ok. I'm sold on having an API for constructing query parameters. > Thoughts on what it should look like? Here's what jQuery does: > > http://api.jquery.com/jQuery.get/ > > Essentially, you supply a JSON object containing the parameters. They > also have some magical syntax for specifying multiple instances of the > same parameter name. I like the easy of supplying a JSON object, but > I'm not in love with the magical syntax. An alternative is to use two > APIs, like we current have for reading the parameter values.
jQuery's syntax isn't magical - the example they give using the query param name of 'choices[]' is doing that because PHP requires a [] at the end of the query param name to signal it that you want multiple values. It's opaque, though - you could just as easily have left off the '[]' and it would have worked the same. The switch is just whether you pass an array or a string (maybe they support numbers too?). I recommend the method be called append*, so you can use it both for first sets and later additions (this is particularly useful if you're just looping through some data). This obviously would then need a clear functionality as well. ~TJ
