Re:Best practices for REST API design (2020)
by e12e on Monday February 22, 2021 @03:56PM
(#26230493)
One reason could be that it's easy to think that a "number" is sanely typed, while you almost never want a double - not for quantity, not for price, etc. So you're going to cast to some (big) integer anyway...
[ Parent
| on HN ]
Re:Best practices for REST API design (2020)
by Kwpolska on Monday February 22, 2021 @05:23PM
(#26231491)
In languages with reasonable number types (i.e. not JS), the parsers are typically able to produce integers, or even BigDecimal, out of a JSON number, without going through double.
Re:Best practices for REST API design (2020)
by e12e on Tuesday February 23, 2021 @05:05AM
(#26235570)
I guess I feel returning error invalid integer for a valid json double is a bit wierd - but I guess it's not technicallyaany worse than "could not parse string as integer. It's more that it is expected that strings hold" other" data, like timestamps, while one might expect a double to hold only (but also any) doubles.