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

Add arbitrary precision support for serde_json deserialization #117

Open
tenuous-guidance opened this issue Oct 26, 2023 · 1 comment
Open

Comments

@tenuous-guidance
Copy link
Contributor

With the 0.4 changes, parsing decimals from JSON results in artefacts from those numbers going via f64. serde-json has support for abitrary precision parsing, which would solve this without reverting to 0.3 behaviour.

This is something I might be able to work on, but I wanted to check if it would be considered first. I think the way rust-decimal handled it is fairly good, and so would probably copy that behaviour if this was considered reasonable.

This is somewhat a duplicate of #113 but wanted to raise it separately as it's more focussed on this particular approach to fixing it.

@akubera
Copy link
Owner

akubera commented Nov 2, 2023

Yeah, that sounds good to me. I'm not familiar with implementing serde transformations. Is it essentially a function mapping &str -> BigDecimal?

I've been splitting code into "impl" modules instead of putting everything in lib.rs. You can make impl_serde.rs and put code and tests in there. Branch off of trunk.

I think we had a limit of serde_json = "<1.0.101" due to incompatibilities with minimum-supported-rust-version 1.43. If that's an issue we'll merge this into an 0.5.0 branch. I'm trying not to stray too far from the num_ crates' MSRV of 1.31.

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

2 participants