-
Notifications
You must be signed in to change notification settings - Fork 183
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
Roundtrip using "serde-float" and "serde-arbitrary-precision" fails #402
Comments
I've raised a #404 for an attempt at fixing this. Let me know what you think! |
Hi @JamesHinshelwood, [package]
name = "rust_decimal_test"
version = "0.1.0"
authors = ["..."]
edition = "2018"
[dependencies]
rust_decimal = { version = "1.14.3", features = ["serde-arbitrary-precision"]}
serde_json = { version = "1.0.64", features = ["arbitrary_precision"] } Or is your issue with the format that it is being serialized to when using |
@paupino Thanks for the response. You're right. Removing the |
@JamesHinshelwood @paupino hope you don't mind me dropping in on this (closed!) issue, as I have some similar use-cases. However, note that the Any chance that the issue could be re-awakened with this in mind? |
The assertion in the following code fails, whereas I would expect it to succeed based on the features I have activated:
main.rs
:Cargo.toml
:Output:
Reading the documentation of
serde-arbitrary-precision
further, it makes it clear that it only supports arbitrary precision when parsing decimals but not when serializing them..to_f64()
is still used in theSerialize
impl which causes the rounding issue.Would you be opposed to extending the behaviour of the
serde-arbitrary-precision
feature to also serializeDecimal
s to JSON numbers exactly, so that the above test would pass?I'd be willing to attempt to contribute this change if you thought it was a good idea.
The text was updated successfully, but these errors were encountered: