Ahhh, OpenFoodFacts and their types...
This commit is contained in:
@@ -23,4 +23,23 @@ public struct NutriscoreData: Sendable, Codable {
|
||||
case energy
|
||||
}
|
||||
|
||||
public init(from decoder: any Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
saturatedFatRatio = try container.decodeIfPresent(
|
||||
Float.self, forKey: .saturatedFatRatio)
|
||||
saturatedFatRatioPoints = try container.decodeIfPresent(
|
||||
Int.self, forKey: .saturatedFatRatioPoints)
|
||||
saturatedFatRatioValue = try container.decodeIfPresent(
|
||||
Float.self, forKey: .saturatedFatRatioValue)
|
||||
|
||||
isBeverage = try container.decodeIfPresent(
|
||||
Int.self, forKey: .isBeverage)
|
||||
isCheese = try container.decodeIfPresent(Int.self, forKey: .isCheese)
|
||||
isWater = try container.decodeStringOrInt(forKey: .isWater)
|
||||
isFat = try container.decodeIfPresent(Int.self, forKey: .isFat)
|
||||
energy = try container.decodeIfPresent(Int.self, forKey: .energy)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user