That is pretty easy with a plain hash like
{:a => \"a\", :b => \"b\"}
which would translate into
\"a=a&b=b\"
<
For basic, non-nested hashes, Rails/ActiveSupport has Object#to_query
.
>> {:a => "a", :b => ["c", "d", "e"]}.to_query
=> "a=a&b%5B%5D=c&b%5B%5D=d&b%5B%5D=e"
>> CGI.unescape({:a => "a", :b => ["c", "d", "e"]}.to_query)
=> "a=a&b[]=c&b[]=d&b[]=e"
http://api.rubyonrails.org/classes/Object.html#method-i-to_query