Return numbers as numbers (and not strings) in the API, store them as numbers in MongoDB, add tests #4389
Labels
API
Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…)
MongoDB
We have 2 mongodb collections: one for current products, and one for obsolete products
⏰ Stale
This issue hasn't seen activity in a while. You can try documenting more to unblock it.
typing
We have this long running issue (see #639) of numbers being sometimes stored as strings in MongoDB or in the JSON returned by the API. We have been fixing many examples of it, but they keep coming back.
It has to do with the way Perl handles scalars: they are automatically converted to strings or to numbers as needed, based on what is being done with them.
So for instance if we use a number as a string (e.g. to display it, to output it to a file, to log it etc.) it will internally become a string.
Unfortunately, the whole world does not use Perl, so it is causing issues for apps that parse the JSON and expect a defined type for each field.
So we need to:
The text was updated successfully, but these errors were encountered: