Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Consistent number decoding #164

Open
ulissesalmeida opened this issue Apr 13, 2023 · 0 comments
Open

Proposal: Consistent number decoding #164

ulissesalmeida opened this issue Apr 13, 2023 · 0 comments

Comments

@ulissesalmeida
Copy link

ulissesalmeida commented Apr 13, 2023

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 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.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant