Data type for proteins_serving, energy-kcal_serving, ... others in nutriments!

Hello! I am using OpenFoodFacts API in a Swift project. When creating my struct for the different data in the API, I listed the data under nutriments (proteins_serving, etc.) as “Double?”. When I run my line of code

print(“More information: calorie content: (String(describing: productResponse.product?.nutriments?.caloriesPerServing)))”)

, it outputs nil.

Please note that when I run the code

print(“Also wondering what the name is: (String(describing: productResponse.product?.productName))”)

, it returns the actual name of the product.

I tried Making the Data type double, float, and int, but none are working. Does anyone have experience with this?

I have resolved this problem! It was with how I structured my structs to call the data. Thank you!

1 Like

Glad you resolved it ! Sorry I was a bit too busy. I don’t want to denounce anyone, but @aleene is also a swift developer :grimacing:

1 Like