-
Notifications
You must be signed in to change notification settings - Fork 41
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
Amount is sent as number, consider string instead #43
Comments
Related discussion #42 |
Related section in our guidelines: http://zalando.github.io/restful-api-guidelines/common-data-objects/CommonDataObjects.html#should-use-a-common-money-object
I hope that spreadsheet is public, otherwise I'll copy the gist here. |
It is true that the problem with serialization type for monetary amount is purely a client side problem. |
@whiskeysierra Looks like the spreadsheet is not public, copying the gist here would be helpful. @AlexanderYastrebov I agree, I'd like to see this use string serialization by default to force clients to think about it and prevent some default client side behavior pitfalls or at least have an easy way to enable the option to do string serialization while supporting either/or for deserialization. |
@Psynbiotik I opened a PR with the discussion rewritten into a somewhat comprehensive document, see #49 |
I wanted to find another page which outlines in more depth the issues, but I could only find the ones below.
A quick summary is some JSON parsers will deserialize numbers as floats which obviously is problematic for Money. Other issues with eventually being deserialized as a float are limitations on size and problems with adding/subtracting. If you send it as a String it will be deserialized as a String.
Various browsers use IEEE-754 to represent their numbers by default which would cause issues.
http://stackoverflow.com/questions/30249406/what-is-the-standard-for-formatting-currency-values-in-json
nlohmann/json#98
shopspring/decimal#21
The text was updated successfully, but these errors were encountered: