Today we have this option: floats: :decimal | :native.
It works pretty when you want Decimal.t() from instead of float, however if the API you're consuming sometimes outputs 3 (integers), you get a native integer number after decoding. So the rest of the code has to handle Decimal.t() or integer() types, or add a code to normalise it before exposing it to the rest of the application.
I wonder if it would be better or possible to have a option like numbers: :binary | :decimal | :native instead. So you could have all numbers normalised in a single shape right (String.t() | Decimal.t() | number()) after decoding.
Hi,
Today we have this option:
floats: :decimal | :native
.It works pretty when you want
Decimal.t()
from instead of float, however if the API you're consuming sometimes outputs3
(integers), you get a native integer number after decoding. So the rest of the code has to handleDecimal.t()
orinteger()
types, or add a code to normalise it before exposing it to the rest of the application.I wonder if it would be better or possible to have a option like
numbers: :binary | :decimal | :native
instead. So you could have all numbers normalised in a single shape right (String.t() | Decimal.t() | number()
) after decoding.What do you think?