uri_query v0.1.2 UriQuery
Summary
Functions
For cases when lists and maps are used in GET parameters
Functions
For cases when lists and maps are used in GET parameters.
Returns keyword list corresponding to given enumerable that is safe to be encoded into a query string.
Keys and Values can be any term that implements the String.Chars
protocol. Lists connot be used as keys.
Values can be lists or maps including nested maps.
Examples
iex> query = %{“foo” => 1, “bar” => 2} iex> UriQuery.params(query) [{"bar", "2"}, {"foo", "1"}]
iex> query = %{foo: ["bar", "baz"]} iex> UriQuery.params(query) [{"foo[0]", "bar"}, {"foo[1]", "baz"}]
iex> query = %{foo: ["bar", "baz"]} iex> UriQuery.params(query, add_indices_to_lists: false) [{"foo[]", "bar"}, {"foo[]", "baz"}]
iex> query = %{“user” => %{“name” => “John Doe”, “email” => “test@example.com”}} iex> UriQuery.params(query) [{"user[email]", "test@example.com"}, {"user[name]", "John Doe"}]