Elixir uses scientific notation by default for floats greater then 1000. This causes an undesired side effect during json serialization.
iex(5)> val = 1000.00
1.0e3
iex(11)> Poison.encode(val)
{:ok, "1.0e3"}
The output I would like is
iex(11)> Poison.encode(val)
{:ok, "1000.00"}
I have seen this answer that uses :erlang.float_to_binary(0.005 * 2.7 / 100, [:compact, {:decimals, 10}])
or :io.format("~f~n",[0.005 * 2.7 / 100])
, but this would require to patch Poison
or to manually check all data before encoding.
Is there a cleaner way to force the default flot to binary format in elixir ?