Michael
Michael4mo ago

Michael - Hello! Not sure how to do this. I hav...

Hello! Not sure how to do this. I have a loop on a json list, and each loop iteration generates an image url. How can I add the generated image url as an object key on the original json list?
No description
Solution:
Hey, in the body of the loop you can save the json in a temporary file and append the new image url field. For this you can use the "Append Array to JSON File" node. Here's a sample workflow thats looping over an array of countries, getting a city for each one using GPT, then using the aforementioned node to append the new field. It then reads the json and returns it. Hopefully this helps: https://buildship.app/remix/a2bd6f42-d22f-4eb9-a54d-062d71d1f7ed
Jump to solution
2 Replies
Solution
Luis
Luis4mo ago
Hey, in the body of the loop you can save the json in a temporary file and append the new image url field. For this you can use the "Append Array to JSON File" node. Here's a sample workflow thats looping over an array of countries, getting a city for each one using GPT, then using the aforementioned node to append the new field. It then reads the json and returns it. Hopefully this helps: https://buildship.app/remix/a2bd6f42-d22f-4eb9-a54d-062d71d1f7ed
Michael
MichaelOP4mo ago
Oh fascinating -- thank you so much @Luis ! Yeah that's exactly what I was missing.