Create JSON from two Lists of Text

I’m trying to take two parameters from backend workflow and use those values to create a text that is JSON formatted.

One backend workflow with two parameters. Both parameters are a list of texts. One parameter is called ‘URL’ and other parameter is called ‘visits’. The two lists have the same number of items and should be matched to each other (meaning the 10th value in the ‘visits’ parameter is the number of visits for the 10th value in the ‘url’ parameter.)

How can I, in the backend workflow, take these two list of texts and combine them into one JSON formatted text? I ultimately want to use that JSON formatted text in an API call to my Bubble app for use of the Bulk update API to create data entries.

Hmm :thinking: Good question. I thought of about three different ways to do this.

  1. Run a loop on both and create the JSON as you go.

  2. Use ChatGPT

  3. Send back a list of numbers using the toolbox plugin so you can use the list of numbers: formatted as text and the match up each with the item number of itself.

I think all of these should work. Number 2 is probably the easiest but more expensive. Number 3 is probably the best solution. Number 1 is probably the hardest.

Just a few ideas to help you start thinking outside of the box. I’m sure there might be other solutions as well. Hope that helps. :blush:

appreciate it @J805

I’m personally more inclined to try out #3 as I like the concept of not needing to use outside services at all. #2 is possible avenue as well if #3 doesn’t work out in regards to matching the two different sets, but I have a gut feeling it will work well.

#1 unfortunately will lead to what I’m ultimately attempting to avoid, which is an unnecessary consumption of WUs. I was helping another user on this, and first step was to re-do the backend workflows they had which were saving these values to the database across multiple backend workflows. We changed it to just use parameters to track these values across the different backend workflows (there are 3 backend workflows that capture these values from separate sources - so 3 sources of the two lists get combined across the 3 backend workflows).

When we got to the end of that, it was clear, a recursive backend workflow to save the values to the database is possible, but too costly now with WUs, so either wanted to schedule a backend workflow on a list to save the values or just run an API call to the Bubble bulk create endpoint.

Sounds good. Hope that gets you going in the right direction. :blush:

1 Like