I just started trying out python, and right now i am in a little bit of a dilemma.
I am trying to print from a json documents, and i am only getting the last element in the array.
[{
"FullMeasure": "1/2 cup",
"FullWeight": "",
"IngredientGridHeaders": null,
"IngredientID": 1142,
"IngredientName": "frozen corn",
"IngredientStep": 10,
"LanguageId": 0,
"PostPreparation": ", thawed, drained",
"PrePreparation": "",
"QuantityNum": 0,
"QuantityText": "1/2",
"QuantityUnit": "cup",
"RecipeIngredientID": 6291555,
"TrialMeasure": "",
"TrialWeight": ""
},
{
"FullMeasure": "1/4 cup",
"FullWeight": "",
"IngredientGridHeaders": null,
"IngredientID": 1523,
"IngredientName": "red pepper",
"IngredientStep": 20,
"LanguageId": 0,
"PostPreparation": "s",
"PrePreparation": "chopped",
"QuantityNum": 0,
"QuantityText": "1/4",
"QuantityUnit": "cup",
"RecipeIngredientID": 6291554,
"TrialMeasure": "",
"TrialWeight": ""
},
{
"FullMeasure": "2 Tbsp.",
"FullWeight": "",
"IngredientGridHeaders": null,
"IngredientID": 20197,
"IngredientName": "chopped green chiles",
"IngredientStep": 30,
"LanguageId": 0,
"PostPreparation": ", drained",
"PrePreparation": "canned ",
"QuantityNum": 2,
"QuantityText": "2",
"QuantityUnit": "Tbsp.",
"RecipeIngredientID": 6291552,
"TrialMeasure": "",
"TrialWeight": ""
},
{
"FullMeasure": "",
"FullWeight": "",
"IngredientGridHeaders": null,
"IngredientID": 19682,
"IngredientName": "KRAFT DELI DELUXE Process American Cheese Slice",
"IngredientStep": 80,
"LanguageId": 0,
"PostPreparation": "s",
"PrePreparation": "",
"QuantityNum": 4,
"QuantityText": "4",
"QuantityUnit": "",
"RecipeIngredientID": 6291558,
"TrialMeasure": "",
"TrialWeight": ""
}
]
I will like to get all the ingredientID, so i wrote this little piece of code to grab the IngredientID
rec = recipes['Recipes'][0]['Ingredients']
for records in rec:
value = {
'Ingredient ID': records['IngredientID']
}
when i return the value, i get
{
"Ingreient ID": 19682
}
I am trying to get the ingredient ID of each element and i just can't seem to figure it out. Any pointers will be well appreciated. Thank you