Arrays in json - how to create them

I have a table with order items and a table with orders

The order items table have the columns order, name and numbers

I need to create a json like below.

I find it hard to create the array using JSON columns - but maybe it isn’t actually possible?

I can create a relation (match multiple) to get all the orderItems - and I lookup a json objects like
{
“name”:“gear”,
“numbers”: 3
}

The lookup’ed column (the above json object) is then transformed by a joined list
Then a template column to add square brackets around the joined list

It seems like when I go down the template column road then json data columns cannot be used to create the final json.

I have tried different ways which can be seen in this demo app:

(FinalJsonNotWorking1, FinalJsonNotWorking2 - yeah, they are not working)

Is there a way to get the json created without using template column - and just using JSON columns.

Final json
{
“company”: “MyCompany”,
“order”: 1010,
“orderItems”:[
{
“name”:“gear”,
“numbers”: 3
},
{
“name”:“wheel”,
“numbers”: 2
}
]
}

FinalJsonNotWorking2
image

image

I haven’t tried it myself but did you do it the same way as in this video?

1 Like

I would definitely have a look. Thx

1 Like

You can try pointing the orderItems variable straight at the lookup, instead of doing this.

1 Like

@ThinhDinh Well your suggestion worked! Cool.
So you just need to have an array of values (like from a multiple relation). Good to know

image

image

1 Like

Yeah, that’s what they rolled out a while ago and it’s much easier than creating template columns :wink:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.