elixir icon indicating copy to clipboard operation
elixir copied to clipboard

Uri query parsing of key with `[]` keyword

Open SocialfiPanda opened this issue 12 years ago • 3 comments

Just a discussion. In Rails and PHP, they parse a uri of something like http://localhost:3000/?foo=1&bar[]=2&bar[]=3to Parameters: {"foo"=>"1", "bar"=>["2", "3"]}.

Yet right now we just treat bar[] as a literal string, so:

iex(1)> URI.decode_query("foo=1&bar[]=2&bar[]=3")                       
%{"bar[]" => "3", "foo" => "1"}

Is one better than another? I will really appreciate any response. :smile:

SocialfiPanda avatar Nov 02 '14 19:11 SocialfiPanda

URI only does a basic parsing, based on &, it does not provide any specific parameter parsing. You can roll your own or use plug (which provides something like PHP/Rails).

And remember to use the mailing list for questions the next time :)

José Valim www.plataformatec.com.br Skype: jv.ptec Founder and Lead Developer

josevalim avatar Nov 02 '14 19:11 josevalim

Thanks!

Will do next time.

SocialfiPanda avatar Nov 02 '14 20:11 SocialfiPanda

Is there any reason why URI only does basic parsing? @jw2013 did you find a roll your own library or did you just end up using plug

CrowdHailer avatar Jun 11 '16 10:06 CrowdHailer