let OriginalTable = datatable(data1:dynamic, data2:dynamic)
[
dynamic({"name":"Name_1","data":[5,6,7,8]}),
dynamic({"name":"Name_2","data":[9,10,11,12]})
];
I have this table. How is it possible to merge those two columns under one column keeping the outcome as a json object.
I tried concatenating them using strcat with "," but it changes the structure of the column.
The expected result should be the following:
{
"name": "Name_1",
"data": [
5,
6,
7,
8
]
},
{
"name": "Name_2",
"data": [
9,
10,
11,
12
]
}
To get output as
Jsondocument by merging two dynamic columns, use below code:The
unionoperator in the above code is used for combining bothdata1anddata2dynamic columns andsummarizeis used for aggregating the resulting rows andmake_listfunction is applied to aggregate all rows into a single list. Each item in this list is a JSON object generated usingpack, which combines thenameanddatafields from each row.Output: