-
Notifications
You must be signed in to change notification settings - Fork 0
Sugar
A Sugar is defined in JSON as follows:
{
"id": "CLOVER_HONEY",
"combined_sugars_total_pct": 0.794,
"density__kg_per_m3": 1.423
}
-
id
must be unique and also paired to the string resource name associated with this Sugar, for translation purposes. (see below) -
combined_sugars_total_pct
is the total amount of sugar percent by volume or by mass (see below) -
density__kg_per_m3
, optional, is the density of the sugar, as mass per unit volume: (see below)
When defining the id
:
- Ensure it is unique among the other
Sugar
definitions. This value is used as the primary key in the database table. - Add an entry in the string resources file at
Must-Watch-Android/app/src/main/res/values/strings.xml
, using theSugar
'sid
value as thename
attribute, and the XML node's value as the human-readable string:<string name="CLOVER_HONEY">clover honey</string>
- Run the unit tests to ensure the database loads the new sugar definition correctly.
To find the total sugar percentage of an ingredient, combined_sugars_total_pct
, we need to find the mass concentration, using this formula:
Recall that volume is in liters, mass is in kilograms.
For more information, refer to the Wikipedia article on mass concentration.
Using Welch's Grape Juice as an example, the nutrition label shows that sugars from carbohydrates are 36g per 240ml serving. We need to convert these units into liters and kilograms, then put it into the formula:
Take Gunter's Pure Clover Honey. The serving size is 1 Tbsp (21g), and the sugars are listed as 16g. Using 21g in the denominator, and converting both values to kg:
Density can be measured using a hydrometer, or if you're lazy, then try to find it online.
This value is used to convert from volume to mass for sugars that are viscous, like honey, that are commonly measured in both volume and mass units. If this value is not provided, it is assumed that this sugar is measured in mass units.