Use JSON as a data source

Hi all!

I’ve been trying to find a solution for this for way too long and I don’t know how to approach this problem. I’m trying to build a table-looking element by nesting 2 repeating groups as suggested in this post (How to create a table with dynamic columns?). The entries to be shown in the RGs are built dynamically (using a Run Javascript element) by prompting the user for input in a few different steps.

Imagine we have categories, each category has attributes and each attribute has values. So the user selects “category 1”, then a multiselect appears where he can select multiple attributes and then for each selected attribute a multidropdown appears where he can select multiple values. I then I build the permutations and generate a data structure like the following:

[
    ["row 1 col 1 value", "row 1 col 2 value", "row 1 col 3 value"],
    ["row 2 col 1 value", "row 2 col 2 value", "row 2 col 3 value"],
    ["row 3 col 1 value", "row 3 col 2 value", "row 3 col 3 value"],
    ...
]

I’m currently using the JSON Manipulator plugin to store the data structure in an element but I can’t seem to be able to use it in as the data source of the repeating group element.
Captura de pantalla 2024-08-23 a las 19.06.40

Does anyone know if this is possible? Or if there’s a better approach?

Thank you in advance.

In your case you will need two repeating group. One for row and inside the row another one for column.

I’m not familiar with JSON manipulator plugin so it’s hard to answer how it work and if this return an array (of array, and an array of text for the row)

I wonder if you could use api connector to make an api call which could be the datasource of the RG

So you build this json yourself? Do you have a valid reason why you built this json structure but not something else?

Because if you build something else like column values are separated by some less likely used character like | and row values are separated by maybe newline, then you can easily use split by for both columns and rows in two repeating groups inside each other.

You can create this two RGs within each other:
image

with this data for example:

row 1 col 1 value|row 1 col 2 value|row 1 col 3 value
row 2 col 1 value|row 2 col 2 value|row 2 col 3 value
row 3 col 1 value|row 3 col 2 value|row 3 col 3 value

By separating the rows by newline for the outer RG. And separating the columns by | for the inner RG.

Thanks for the responses!

@boston85719 I thought of doing that at some point but I’m a bit reluctant of making API requests as that’ll slow down things. Thanks for the suggestion though!

@hergin No specific reason to use JSON, I just think it’s cleaner… I went with your suggestion and I’m using a list of strings in a specific format. Then set that value in the state of an element and use that as data source.

Thank you again!