-
Notifications
You must be signed in to change notification settings - Fork 393
JSON deserialization of quantities that use decimal internally may fail #847
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
Comments
Thank you for a good repro on this issue. I believe this can be solved by making the serializer smarter in handling Would you be interested in attempting a pull request on this? I'll be happy to assist. |
I created PR #868 to fix the issue. Since But I still don't understand what is so special about the |
Great, yes JSON number is probably restricted to represent the precision provided by decimal. The reason Power has decimal, but not Luminosity is not intentional. Introducing decimal was a design mistake to begin with, because it complicates a lot of things having different number types for different quantities. We haven't found a good solution for this yet. The reason decimal was added was that round-trip conversion unit tests failed when adding very large/small units to certain quantities, and I believe Power was one of the first to encounter this. Why Luminosity didn't receive the same treatment I'm not sure, maybe the round-trip conversion stopped being a problem at some point - I haven't investigated. At any rate, I'd love to get rid of |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Fixed by #868 |
Describe the bug
When serializing and deserializing quantities that use the
decimal
type for storage interally, JSON deserialization using the converters from UnitsNet.Serialization.JsonNet may fail with anOverflowException
if the value is too big or too large.To Reproduce
Steps to reproduce the behavior (just an example):
Example failed test result:
Expected behavior
No tests fail.
The text was updated successfully, but these errors were encountered: