My API returns a a list with a nested list. There is a list of subject data type (Subject body subject) that contains a list of case date type (Subject case) . I want to save the content into DB.
In the backend, both data types are not available in API WF. Without them I can’t do recursive loop. Why is that?
In the front end, I can have access to the 2 data types, but I can’t pass them to the backend to do the looping so the subject can be created before the subject is available when creating the cases.
I have created something like this, but I still don’t know how to I can loop through the subject list and then loop through the case list to save the data into a Bubble data type.
After searching on the forum with “nested JSON to database”, it seems that it is not possible in Bubble. I need to flattern the JSON with javascripg/plugin/external service.
In some cases, it would be sufficient to store the whole object in a field of one data type (so there is no need for looping), and then access its nested lists from the frontend and display their content
Displaying nested list to RG is not a problem. However, I need to save the individual data to the DB, so I need to do recursive workflow where the API data type is not available on the API WF.
Handling multi level JSON responses in bubble is a nightmare.
All I can think of is if there is a 2 level of grouping of responses you can launch a loop. In 3 level you would need to launch a loop in a loop which maybe very costly.
My current go-to solution is to do level 2 in a loop within a loop. Agree about the potential WU cost of level 3 but you should probably also consider limits, of some kind. For example, in my BE WF loops I use Counter and Max to loop, and stop loops. I also have an ‘and’ with a hard limit on the Max variable.
counter < max and max < 250
(for example - to ensure there’s a hard limit somewhere). |
I also store level 2 json into Supabase if I need it, I’ll call that json back on demand (if that demand ever surfaces).