Skip to content

Instantly share code, notes, and snippets.

@halfbyte
Forked from tow8ie/answers.rb
Created May 3, 2011 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halfbyte/953312 to your computer and use it in GitHub Desktop.
Save halfbyte/953312 to your computer and use it in GitHub Desktop.
Rack Nested Params Parsing Quiz My Solution
"x[y][z]=1" # => {"x" => {"y" => {"z" => "1"}}}
"x[y][z][]=1" # => {"x" => {"z" => ["1"]}
"x[y][z]=1&x[y][z]=2" # => {"x" => {"z" => ["1", "2"]}
"x[y][z][]=1&x[y][z][]=2" # => {"x" => {"y" => {"z" => ["1", "2"]}}
"x[y][][z]=1" # => {"x" => {"y" => [{"z" => "1"}]}}
"x[y][][z][]=1" # => {"x" => {"y" => [{"z => ["1"]}]}}
"x[y][][z]=1&x[y][][w]=2" # => {"x" => {"y" => [{"z => "1"}, {"w" => "2"]}}
"x[y][][v][w]=1" # => {"x" => {"y" => [{"v" => {"w" => "1"}}]}}
"x[y][][z]=1&x[y][][v][w]=2" # => {"x" => {"y" => [{"z" => "1"}, {"v" => {"w" => "1"}}]}}
"x[y][][z]=1&x[y][][z]=2" # => {"x" => {"y" => [{"z" => "1"}, {"z" => "2"}]}}
"x[y][][z]=1&x[y][][w]=a&x[y][][z]=2&x[y][][w]=3" # => {"x" => {"y" => [{"z" => "1"}, {"w" => "a"}, {"z" => "2"}, {"w" => "3"}]}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment