Created
May 3, 2011 12:35
-
-
Save tow8ie/953254 to your computer and use it in GitHub Desktop.
Rack Nested Params Parsing Quiz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See https://github.com/rack/rack/blob/master/test/spec_utils.rb | |
# and http://www.ruby-forum.com/topic/215584 | |
# for further details and historical explanation | |
"x[y][z]=1" # => {"x" => {"y" => {"z" => "1"}}} | |
"x[y][z][]=1" # => {"x" => {"y" => {"z" => ["1"]}}} | |
"x[y][z]=1&x[y][z]=2" # => {"x" => {"y" => {"z" => "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" => "2"}}]}} | |
"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"}]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"x[y][z]=1" # => {"x" => {"y" => {"z" => "1"}}} | |
"x[y][z][]=1" # => | |
"x[y][z]=1&x[y][z]=2" # => | |
"x[y][z][]=1&x[y][z][]=2" # => | |
"x[y][][z]=1" # => | |
"x[y][][z][]=1" # => | |
"x[y][][z]=1&x[y][][w]=2" # => | |
"x[y][][v][w]=1" # => | |
"x[y][][z]=1&x[y][][v][w]=2" # => | |
"x[y][][z]=1&x[y][][z]=2" # => | |
"x[y][][z]=1&x[y][][w]=a&x[y][][z]=2&x[y][][w]=3" # => |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment