diff --git a/Sources/OpenFoodFacts/Schemas/Nutriments.swift b/Sources/OpenFoodFacts/Schemas/Nutriments.swift index f8717fb..db0b77e 100644 --- a/Sources/OpenFoodFacts/Schemas/Nutriments.swift +++ b/Sources/OpenFoodFacts/Schemas/Nutriments.swift @@ -258,6 +258,27 @@ extension Nutriments { public var sodium: Nutrient? { nutrients["sodium"] } public var sugars: Nutrient? { nutrients["sugars"] } public var calcium: Nutrient? { nutrients["calcium"] } + + public var otherNutrients: [String: Nutrient] { + var others = nutrients + others.removeValue(forKey: "alcohol") + others.removeValue(forKey: "carbohydrates") + others.removeValue(forKey: "energy") + others.removeValue(forKey: "energy_kj") + others.removeValue(forKey: "energy_kcal") + others.removeValue(forKey: "fat") + others.removeValue( + forKey: "fruits_vegetables_nuts_estimate_from_ingredients") + others.removeValue(forKey: "nova_group") + others.removeValue(forKey: "proteins") + others.removeValue(forKey: "salt") + others.removeValue(forKey: "saturated_fat") + others.removeValue(forKey: "sodium") + others.removeValue(forKey: "sugars") + others.removeValue(forKey: "calcium") + + return others + } } extension Nutriments: Sequence, IteratorProtocol {