Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 6bf0557010
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 16 lines (10 sloc) 0.563 kb

QueryParams

A straight forward gem to convert ruby hashes and arrays to http query strings following the query string conventions of Rails and Sinatra. It supports hashes, arrays, nested hashes and arrays of hashes and all combinations thereof. E.g.:

QueryParams.encode({a: 1, b: "c"})
=> "a=1&b=c"

QueryParams.encode({a: {b: 'c', d: 'e'}, f: 'g'})
=> "a[b]=c&a[d]=e&f=g"

QueryParams.encode({a: ['bingo', 'hepp']})
=> "a[0]=bingo&a[1]=hepp"

QueryParams.encode({a: [{b:'c', d:'e'}, {b:'g'}]})
=> "a[][b]=c&a[][d]=e&a[][b]=g"
Something went wrong with that request. Please try again.