Hi, I've been using this library through Stripity Stripe and directly in my app to encode maps with lists as application/www-form-urlencoded. One pain point with the library is how it treats nil values in an elixir map when calling params/1. For example, if I have the map that has a nil value
UriQuery.params(%{a: nil})
[{"a", ""}]
Not all APIs treat the empty string as if it were the same as nil, such as Stripe, and it can require additional processing of the returned list from params/1 to make things work correctly. It would be useful if an additional keyword arg could be passed in to control how nil values are handled, such as
UriQuery.params(%{a: nil}, replace_nil: "null")
[{"a", "null"}]
or simpler
UriQuery.params(%{a: nil, b: "c"}, drop_nil: true)
[{"b", "c"}]
If this seems like a good idea, I could take a shot at implementing it and putting up a PR!
Hi, I've been using this library through Stripity Stripe and directly in my app to encode maps with lists as
application/www-form-urlencoded. One pain point with the library is how it treats nil values in an elixir map when callingparams/1. For example, if I have the map that has a nil valueNot all APIs treat the empty string as if it were the same as nil, such as Stripe, and it can require additional processing of the returned list from
params/1to make things work correctly. It would be useful if an additional keyword arg could be passed in to control how nil values are handled, such asor simpler
If this seems like a good idea, I could take a shot at implementing it and putting up a PR!