Processing JSON in a column/data format

Hi Bubble community,

Has anyone had to handle an API call that provided a response similar to the below, where first it stated the column headers and then the provided the response data like the below example? I would like to create a new data thing for each response row with the different fields aligning to the column headers but since its not in a key value pair style, its not as simple. Any suggestions would be much appreciated.

{
“columns”: [
“id”,
“column_1”,
“column_2”,
“column_3”
],
“data”: [
[
1,
“response1_col_1”,
“response1_col_2”,
“response1_col_3”
],
[
2,
“response2_col_1”,
“response2_col_2”,
“response2_col_3”
]
]
}

You can use backend workflows. Make a backend workflow that takes in two different lists of texts. One of the lists would be columns and the other would be data

Action1) Create a thing and use columns:first item and data:first item
Action 2) Schedule API Workflow and choose the workflow you are creating to run again and when you pass the list of texts columns would equal columns:minus item columns:first item and data would equal data:minus item data:first item. Add a conditional on this step to only run if columns:minus item columns:first item count > 0.

When you get the return from the api pass the columns and data to the newly created backend workflow. This may not exactly work for the way your data is returned or how it needs to be saved but this is the general idea.

2 Likes

Thank you @williamtisdale this was very helpful.

This topic was automatically closed after 70 days. New replies are no longer allowed.