{
  "title": "Open Food Log v0: amount vectors",
  "description": "Worked cases every implementation should agree on: an amount on a food becomes grams, then the item's nutrients. grams and nutrients are exact; an implementation that rounds what it stores (to two decimal places, say) agrees when it is within 0.01. Only four nutrients are listed per case; the rule is the same for all. An error is the code an implementation reports instead of guessing.",
  "foods": [
    {
      "$schema": "https://openfoodlog.org/schema/v0/food.json",
      "id": "ofc:egg-whole-raw",
      "name": "Egg, Whole, Raw",
      "kind": "generic",
      "aliases": [
        {
          "name": "egg",
          "kind": "common"
        },
        {
          "name": "eggs",
          "kind": "common"
        }
      ],
      "nutrients_per_100g": {
        "energy_kcal": 143,
        "protein_g": 12.56,
        "fat_g": 9.51,
        "saturated_fat_g": 3.126,
        "monounsaturated_fat_g": 3.658,
        "polyunsaturated_fat_g": 1.911,
        "trans_fat_g": 0.038,
        "cholesterol_mg": 372,
        "carbohydrate_g": 0.72,
        "fiber_g": 0,
        "sugars_g": 0.37,
        "sodium_mg": 142,
        "potassium_mg": 138,
        "calcium_mg": 56,
        "iron_mg": 1.75,
        "magnesium_mg": 12,
        "zinc_mg": 1.29,
        "vitamin_c_mg": 0,
        "vitamin_d_ug": 2,
        "vitamin_a_rae_ug": 160,
        "caffeine_mg": 0,
        "alcohol_g": 0,
        "water_g": 76.15
      },
      "portions": [
        {
          "id": "small",
          "label": "1 small",
          "grams": 38
        },
        {
          "id": "medium",
          "label": "1 medium",
          "grams": 44
        },
        {
          "id": "large",
          "label": "1 large",
          "grams": 50,
          "is_default": true
        },
        {
          "id": "extra-large",
          "label": "1 extra large",
          "grams": 56
        },
        {
          "id": "jumbo",
          "label": "1 jumbo",
          "grams": 63
        }
      ],
      "identifiers": {
        "fdc_id": 171287
      },
      "provenance": {
        "sources": [
          {
            "name": "USDA FoodData Central (SR Legacy)",
            "id": "171287",
            "url": "https://fdc.nal.usda.gov/food-details/171287/nutrients",
            "license": "CC0-1.0",
            "retrieved_at": "2026-11-09"
          }
        ],
        "license": "CC0-1.0",
        "review": "unreviewed"
      }
    },
    {
      "$schema": "https://openfoodlog.org/schema/v0/food.json",
      "id": "ofc:oats-dry",
      "name": "Oats, Dry",
      "kind": "generic",
      "aliases": [
        {
          "name": "oatmeal",
          "kind": "common"
        },
        {
          "name": "rolled oats",
          "kind": "common"
        },
        {
          "name": "porridge oats",
          "kind": "common"
        }
      ],
      "nutrients_per_100g": {
        "energy_kcal": 379,
        "protein_g": 13.15,
        "fat_g": 6.52,
        "saturated_fat_g": 1.11,
        "monounsaturated_fat_g": 1.98,
        "polyunsaturated_fat_g": 2.3,
        "cholesterol_mg": 0,
        "carbohydrate_g": 67.7,
        "fiber_g": 10.1,
        "sugars_g": 0.99,
        "sodium_mg": 6,
        "potassium_mg": 362,
        "calcium_mg": 52,
        "iron_mg": 4.25,
        "magnesium_mg": 138,
        "zinc_mg": 3.64,
        "vitamin_c_mg": 0,
        "vitamin_d_ug": 0,
        "vitamin_a_rae_ug": 0,
        "caffeine_mg": 0,
        "alcohol_g": 0,
        "water_g": 10.84
      },
      "portions": [
        {
          "id": "cup",
          "label": "1 cup",
          "grams": 81
        }
      ],
      "identifiers": {
        "fdc_id": 173904
      },
      "provenance": {
        "sources": [
          {
            "name": "USDA FoodData Central (SR Legacy)",
            "id": "173904",
            "url": "https://fdc.nal.usda.gov/food-details/173904/nutrients",
            "license": "CC0-1.0",
            "retrieved_at": "2026-11-09"
          }
        ],
        "license": "CC0-1.0",
        "review": "unreviewed"
      }
    },
    {
      "$schema": "https://openfoodlog.org/schema/v0/food.json",
      "id": "ofc:banana-raw",
      "name": "Banana, Raw",
      "kind": "generic",
      "aliases": [
        {
          "name": "banana",
          "kind": "common"
        },
        {
          "name": "bananas",
          "kind": "common"
        }
      ],
      "nutrients_per_100g": {
        "energy_kcal": 89,
        "protein_g": 1.09,
        "fat_g": 0.33,
        "saturated_fat_g": 0.112,
        "monounsaturated_fat_g": 0.032,
        "polyunsaturated_fat_g": 0.073,
        "trans_fat_g": 0,
        "cholesterol_mg": 0,
        "carbohydrate_g": 22.84,
        "fiber_g": 2.6,
        "sugars_g": 12.23,
        "sodium_mg": 1,
        "potassium_mg": 358,
        "calcium_mg": 5,
        "iron_mg": 0.26,
        "magnesium_mg": 27,
        "zinc_mg": 0.15,
        "vitamin_c_mg": 8.7,
        "vitamin_d_ug": 0,
        "vitamin_a_rae_ug": 3,
        "caffeine_mg": 0,
        "alcohol_g": 0,
        "water_g": 74.91
      },
      "portions": [
        {
          "id": "extra-small",
          "label": "1 extra small (under 6\")",
          "grams": 81
        },
        {
          "id": "small",
          "label": "1 small (6\" to 7\")",
          "grams": 101
        },
        {
          "id": "medium",
          "label": "1 medium (7\" to 8\")",
          "grams": 118,
          "is_default": true
        },
        {
          "id": "large",
          "label": "1 large (8\" to 9\")",
          "grams": 136
        },
        {
          "id": "cup-sliced",
          "label": "1 cup, sliced",
          "grams": 150
        }
      ],
      "identifiers": {
        "fdc_id": 173944
      },
      "provenance": {
        "sources": [
          {
            "name": "USDA FoodData Central (SR Legacy)",
            "id": "173944",
            "url": "https://fdc.nal.usda.gov/food-details/173944/nutrients",
            "license": "CC0-1.0",
            "retrieved_at": "2026-11-09"
          }
        ],
        "license": "CC0-1.0",
        "review": "unreviewed"
      }
    },
    {
      "$schema": "https://openfoodlog.org/schema/v0/food.json",
      "id": "ofc:milk-whole",
      "name": "Milk, Whole (3.25%)",
      "kind": "generic",
      "aliases": [
        {
          "name": "whole milk",
          "kind": "common"
        },
        {
          "name": "milk",
          "kind": "common"
        }
      ],
      "nutrients_per_100g": {
        "energy_kcal": 61,
        "protein_g": 3.15,
        "fat_g": 3.25,
        "saturated_fat_g": 1.865,
        "monounsaturated_fat_g": 0.812,
        "polyunsaturated_fat_g": 0.195,
        "cholesterol_mg": 10,
        "carbohydrate_g": 4.8,
        "fiber_g": 0,
        "sugars_g": 5.05,
        "sodium_mg": 43,
        "potassium_mg": 132,
        "calcium_mg": 113,
        "iron_mg": 0.03,
        "magnesium_mg": 10,
        "zinc_mg": 0.37,
        "vitamin_c_mg": 0,
        "vitamin_d_ug": 1.3,
        "vitamin_a_rae_ug": 46,
        "caffeine_mg": 0,
        "alcohol_g": 0,
        "water_g": 88.13
      },
      "density_g_per_ml": 1.031,
      "portions": [
        {
          "id": "cup",
          "label": "1 cup",
          "grams": 244
        },
        {
          "id": "tbsp",
          "label": "1 tbsp",
          "grams": 15
        }
      ],
      "identifiers": {
        "fdc_id": 171265
      },
      "provenance": {
        "sources": [
          {
            "name": "USDA FoodData Central (SR Legacy)",
            "id": "171265",
            "url": "https://fdc.nal.usda.gov/food-details/171265/nutrients",
            "license": "CC0-1.0",
            "retrieved_at": "2026-11-09"
          }
        ],
        "license": "CC0-1.0",
        "review": "unreviewed"
      }
    }
  ],
  "cases": [
    {
      "name": "grams as given",
      "food": "ofc:egg-whole-raw",
      "amount": {
        "value": 150,
        "unit": "g"
      },
      "expect": {
        "grams": 150,
        "nutrients": {
          "energy_kcal": 214.5,
          "protein_g": 18.84,
          "fat_g": 14.265,
          "carbohydrate_g": 1.08
        }
      }
    },
    {
      "name": "a named portion",
      "food": "ofc:egg-whole-raw",
      "amount": {
        "value": 3,
        "unit": "portion",
        "portion": "large"
      },
      "expect": {
        "grams": 150,
        "nutrients": {
          "energy_kcal": 214.5,
          "protein_g": 18.84,
          "fat_g": 14.265,
          "carbohydrate_g": 1.08
        }
      }
    },
    {
      "name": "a fraction of a portion",
      "food": "ofc:oats-dry",
      "amount": {
        "value": 0.5,
        "unit": "portion",
        "portion": "cup"
      },
      "expect": {
        "grams": 40.5,
        "nutrients": {
          "energy_kcal": 153.495,
          "protein_g": 5.32575,
          "fat_g": 2.6406,
          "carbohydrate_g": 27.4185
        }
      }
    },
    {
      "name": "ounces",
      "note": "1 oz = 28.349523125 g exactly.",
      "food": "ofc:oats-dry",
      "amount": {
        "value": 2,
        "unit": "oz"
      },
      "expect": {
        "grams": 56.69904625,
        "nutrients": {
          "energy_kcal": 214.8893852875,
          "protein_g": 7.455924581875,
          "fat_g": 3.6967778155,
          "carbohydrate_g": 38.38525431125
        }
      }
    },
    {
      "name": "pounds",
      "note": "1 lb = 453.59237 g exactly.",
      "food": "ofc:banana-raw",
      "amount": {
        "value": 0.25,
        "unit": "lb"
      },
      "expect": {
        "grams": 113.3980925,
        "nutrients": {
          "energy_kcal": 100.924302325,
          "protein_g": 1.23603920825,
          "fat_g": 0.37421370525,
          "carbohydrate_g": 25.900124327
        }
      }
    },
    {
      "name": "kilograms",
      "food": "ofc:banana-raw",
      "amount": {
        "value": 0.2,
        "unit": "kg"
      },
      "expect": {
        "grams": 200,
        "nutrients": {
          "energy_kcal": 178,
          "protein_g": 2.18,
          "fat_g": 0.66,
          "carbohydrate_g": 45.68
        }
      }
    },
    {
      "name": "millilitres through density",
      "food": "ofc:milk-whole",
      "amount": {
        "value": 250,
        "unit": "ml"
      },
      "expect": {
        "grams": 257.75,
        "nutrients": {
          "energy_kcal": 157.2275,
          "protein_g": 8.119125,
          "fat_g": 8.376875,
          "carbohydrate_g": 12.372
        }
      }
    },
    {
      "name": "litres through density",
      "food": "ofc:milk-whole",
      "amount": {
        "value": 0.5,
        "unit": "l"
      },
      "expect": {
        "grams": 515.5,
        "nutrients": {
          "energy_kcal": 314.455,
          "protein_g": 16.23825,
          "fat_g": 16.75375,
          "carbohydrate_g": 24.744
        }
      }
    },
    {
      "name": "US fluid ounces through density",
      "note": "1 US fl oz = 29.5735295625 ml exactly.",
      "food": "ofc:milk-whole",
      "amount": {
        "value": 8,
        "unit": "fl_oz"
      },
      "expect": {
        "grams": 243.9224718315,
        "nutrients": {
          "energy_kcal": 148.792707817215,
          "protein_g": 7.68355786269225,
          "fat_g": 7.92748033452375,
          "carbohydrate_g": 11.708278647912
        }
      }
    },
    {
      "name": "a volume with no density",
      "note": "Eggs here have no density, so a volume can't be weighed. Don't assume 1 g/ml.",
      "food": "ofc:egg-whole-raw",
      "amount": {
        "value": 100,
        "unit": "ml"
      },
      "expect": {
        "error": "density_unknown"
      }
    },
    {
      "name": "a portion the food doesn't have",
      "food": "ofc:oats-dry",
      "amount": {
        "value": 1,
        "unit": "portion",
        "portion": "tbsp"
      },
      "expect": {
        "error": "portion_unknown"
      }
    }
  ]
}
