How to groupby using Dataweave

446 Views Asked by At

I am new to Mulesoft and would like to know how to do the following using Dataweave (we are using Mulesoft 3.8...) - instead of using Java or PHP or even TSQL etc

We have a table with the following information:

ID col1 col2 col3 1 A a1 aa1 2 A a2 aa2 3 B b1 bb1 4 B b2 bb2

My aim is to read the data from the table and pass it through a Transform Message to output the following data in a JSON format

Basically I would like the data as follows but in JSON format

[
{
  "info1": A,
  "info2": [
{
  "accesslevel": [
     {
        "morning: 
           {
             "level1: a1,
             "level2":aa1
           },
        "evening": 
           {
             "level1": a2,
             "level2": aa2
           }
         ]
        },

etc...

A a1 aa1 a2 aa2 B b1 bb1 b2 bb2 C c1 cc1 c2 cc2

Kind regards Taki

0

There are 0 best solutions below