|
|
|
|
|
by treve
2144 days ago
|
|
Yes, but almost any standard JSON package will map a number with decimals to their internal float. While alternative parsers exists (javascript has LosslessJSON for example), they're a pain to use. Using strings for floats only has a tiny overhead, but it allows users to use standard JSON parsers and it signals a good practice. If you use JSON numbers to serialize money, you create a situation where the path with the least friction is the incorrect one. |
|
FWIW in Python that's as uncomplicated as
though of course it helps tremendously that `decimal` is part of the stdlib.