Skip to content
This repository was archived by the owner on Apr 16, 2025. It is now read-only.
Pierre Slamich edited this page Feb 1, 2021 · 5 revisions

Questions asked in the Slack

Volume to Weight conversions

Am I right to assume that servings get converted between volume and weight 1:1? Eg. 240ml will be calculated as 240g? Example: { "_id": "0071464302511" "serving_size": "8 OZA (240 ml)", "serving_size_imported": "8 OZA (240 ml)", "serving_quantity": 240, // ml "nutrition_data_per_imported": "100g", "nutrition_data_per": "100g", "nutriments": { "calcium_100g": 0.008, // g "calcium_serving": 0.019200000000000002, // 0.08*2.4 "calcium_unit": "mg", "calcium_value": 8, // mg } } Not sure how to import this data, because weight/volume conversions depend on density (eg. 1g of beer is 0.98ml, 1g of olive oil is 1.09ml) so if the nutrition data is per "100g" then the serving data can be incorrect if the serving is volume. The bigger problem is if the "nutrition_data_per": "serving", then the "nutrient_100g" values are likely to be incorrect if the serving was in volume, and we don't know also the weight of the serving. So in this case the nutrient values are actually for 100ml, instead of 100g, but currently there is no prop on the foods indicating if the nutrients are for volume instead of weight, except maybe parsing the "serving_size" string. Do you have any ideas how to best handle this?

Answer

we assume 1 g = 1 ml, it's not perfect, but it's reasonably close for most products

Clone this wiki locally