Skip to content

Instantly share code, notes, and snippets.

@ltfschoen
Created January 28, 2018 07:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ltfschoen/a52109ea5a9e020fa4abcaacbc43e8af to your computer and use it in GitHub Desktop.
Save ltfschoen/a52109ea5a9e020fa4abcaacbc43e8af to your computer and use it in GitHub Desktop.
Elixir Convert Query String Parameters into Map (Key/Value Pairs)
# Convert Query String Parameters into Map (Key/Value Pairs)
# Output is: `%{"from" => "ME", "proof" => "PROVEN", "to" => "YOU", "to_index" => "THERE"}`
String.split("from=ME&to=YOU&to_index=THERE&proof=PROVEN", ~r/&|=/) |> Enum.chunk(2) |> Map.new(fn [k, v] -> {k, v} end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment