'How to format decoded JSON string into usable pieces in Swift?

I have the components I want to see in my print screen, but now I'm trying to format the results of a decoded JSON into something more usable. Here's my current code:

do {
         let macros = try JSONDecoder().decode(Instruction.self, from: data)
                    
         print(macros)
}

and the result prints:

Instruction(foods: [Multiple_Views.Food(nfCalories: 105.02, nfTotalFat: 0.39, nfTotalCarbohydrate: 26.95, nfDietaryFiber: 3.07, nfProtein: 1.29)])

How do I separate each component (Calories, Fat, Carbs, Fiber, Protein) so I can display them to the user individually? I'm having trouble using regex on 'macros' because Swift says

Cannot convert value of type 'Instruction' to expected argument type 'String'



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source