Simple Conditional

Conditionals

Simple Conditional

Task

Build an object per line item containing the product_id and the subtotal (quantity*unit_price). If either quantity or unit_price does not exist, the "subtotal" key should not exist.

Your Expression
Your Result
No data
Input JSON
{
    line_items:[
      {
        product_id:1
      },
      {
        product_id:2,
        quantity:53,
        unit_price:10.876
      }
    ]
}
Expected Output
[
    {
      product_id:1
    },
    {
      product_id:2,
      subtotal:576.428
    }
]