Overview
Assume we have below query param string
a=b&x=y
We want the output as
{
"a" => "b",
"x" => "y"
}
Program
Below is the program for the same
input_sring = 'a=b&x=y'
query_params_hash = {}
input_string_split = input_sring.split('&')
input_string_split.each do |q|
q_split = q.split('=')
query_params_hash[q_split[0]] = q_split[1]
end
puts query_params_hash
Output
{"a"=>"b", "x"=>"y"}