Struggling with creating JSON

Hi.
I am a beginner user and I have encountered the following problem. I have a block that returns 4 different values and each of them is an array.

image

And my goal is to iterate thought this but i can’t. My idea is to first create proper JSON in format as in the example below
[
{
“id”: “123”
“name”: “event 1”,
“date”: “2023/01/10”,
“calendar_id”: “33”
},
{
“id”: “321”
“name”: “event 2”,
“date”: “2023/01/11”,
“calendar_id”: “12”
},
]

If you know how to do it, let me know :slight_smile:

Hi,

If each of these arrays has just one element, and that’s what your interested in, for example
id: [123]
name: [John]

Then what you can do is use a parse Json Module and inside your module structure it like this:

{
“id”: get(id;1)
“name”: get(name;1)
}

Here your just assigning id, name… and so on, to the first element in the array, note that in this IML Get() function, that array should be mapped from the arrays in your screenshot.

4 Likes

Hi. Thank you for the answer.
The issue is that I don’t know how many elements I will have. This means that it may be 0 or may be 4 so i have to somehow dynamically assign this this.

Welcome to the Make community!

What you can do is simply “Aggregate to JSON”.

In each of the fields, use the built-in function first to get the value in the array, of each property from the OpenAI module.

You’ll have to create a simple data structure for this – let me know if you need help doing it!

Output

Screenshot_2024-01-12_090119

3 Likes