Created
January 28, 2018 07:38
-
-
Save ltfschoen/a52109ea5a9e020fa4abcaacbc43e8af to your computer and use it in GitHub Desktop.
Elixir Convert Query String Parameters into Map (Key/Value Pairs)
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
# 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