Composition

Calculation & Aggregation

Composition

Task

Build a "flattened" array of all items regardless of whether they are a main or sub item. The order is not important for this exercise.

Hint: This requires understanding array functions

Your Expression
Your Result
No data
Input JSON
{
    line_items:[
      {
        product_id:1,
        sub_line_items:[
          {
            product_id:3,
            quantity:5,
            unit_price:10
          }
        ]
      },
      {
        product_id:2,
        quantity:53,
        unit_price:10.876,
        sub_line_items:[
          {
            product_id:4,
            quantity:3,
            unit_price:10.99
          },
          {
            product_id:5,
            quantity:9,
            unit_price:44.77
          }
        ]
      }
    ]
}
Expected Output
[
    {
      product_id:1
    },
    {
      product_id:2
    },
    {
      product_id:3
    },
    {
      product_id:4
    },
    {
      product_id:5
    }
]