Merge two lists (key value pairs)

Hey everybody,

I’m using an external API that returs data on a list of Key Value Pairs like this:

“United States”: [
{
“Key”: “Florida”,
“Value”: “Tallahassee”
},
{
“Key”: “Utah”,
“Value”: “Salt Lake City”
},
{
“Key”: “Nevada”,
“Value”: “Carson City”
}

The list is always 1 to 1, meaning 1 Key for 1 Value.

When I save “Key” and “Value” to my Bubble Data Base I actually save the list that was return… something like this:

Key = Florida, Utah, Nevada
Value = Tallahassee, Salt Lake City, Carson City

How can I save on my Bubble Data Base on line (two columns) for each pair… something like

Item#1
Column Key = Florida
Column Value = Tallahassee

Item#2
Column Key = Utah
Column Value = Salt Lake City

ID#3
Column Key = Nevada
Column Value = Carson City

I need to do that within a Workflow… any ideas?

@NigelG
@louisadekoya
@romanmg

1 Like

You could run an API workflow on the list returned from your API call. If your key and value data are returned in one list, you can have one action that creates a record for each item in your list, setting the key and value. Otherwise, you might need two workflows - the first workflow would create a record for each Key and record the item #, then the second workflow could update the same records setting the Value of each record to the returned value with a matching item #. I hope this makes sense.

An alternative may be to use the list expression of the toolbox plugin in some way.

1 Like